• Halloween is coming! To celebrate the occasion, we dusted off a couple of old skins, and even created a brand new one (Pixel).
    To get into the festive spirit, install the Skins extension.
  • The new Python extension is now available. It allows customers to deploy and manage WSGI-based Python applications on their websites directly from Plesk.
  • The Plesk Mobile apps for iOS and Android and the Plesk Mobile Center extension have been deprecated, and are no longer available for new installations. In Plesk Obsidian 18.0.84, the Plesk Mobile Center extension will be removed from servers during the upgrade, and the Plesk Mobile apps will lose their server management features.
  • The Social Login extension has been deprecated and will be removed in Plesk Obsidian 18.0.84. After that, it will no longer be possible to log in to Plesk with a Google, Facebook, GitHub account, or with a passkey. Plesk usernames and passwords, as well as logging in with a WebPros Account, are not affected.

Question python code generates apache handler error

elenaflorence

New Pleskian

Hello I execute this python code below​

#!/usr/bin/python
print "Content-Type: text/html\n\n";
print "<html><head>";
print "<title>CGI Test</title>";
print "</head><body>";
print "<p>Test page using Python</p>";
print "</body></html>";

import requests
from bs4 import BeautifulSoup
import sys


url='https://kelponton.fr'

page = requests.get(url)
soup = BeautifulSoup(page.content, 'html.parser')

print(soup.prettify())

"Test page using Python" is well displaying meaning python is working but when I had the line print(soup.prettify()), i have the following errors in the logs (it seems something not well installed with handlers ?) My website is running on Apache/Centos7 and Plesk Thank you for help
--------------------------------------
2020-09-14 22:21:12 Error 82.229.61.242 500 GET /admin_sohapply/webscrapp/test5.py HTTP/1.0 Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.102 Safari/537.36 2.01 K Accès SSL/TLS Apache
2020-09-14 22:21:13 Error 82.229.61.242 PythonHandler mod_python.cgihandler: Traceback (most recent call last): Erreur Apache
2020-09-14 22:21:13 Error 82.229.61.242 PythonHandler mod_python.cgihandler: File "/usr/lib64/python2.7/site-packages/mod_python/apache.py", line 398, in HandlerDispatch\n result = obj(req) Erreur Apache
2020-09-14 22:21:13 Error 82.229.61.242 PythonHandler mod_python.cgihandler: File "/usr/lib64/python2.7/site-packages/mod_python/cgihandler.py", line 96, in handler\n imp.load_module(module_name, fd, path, desc) Erreur Apache
2020-09-14 22:21:13 Error 82.229.61.242 PythonHandler mod_python.cgihandler: File "/var/www/vhosts/bibelotandco.fr/httpdocs/admin_sohapply/webscrapp/test5.py", line 16, in <module>\n page = requests.get(url) Erreur Apache
2020-09-14 22:21:13 Error 82.229.61.242 PythonHandler mod_python.cgihandler: File "/usr/lib/python2.7/site-packages/requests/api.py", line 68, in get\n return request('get', url, **kwargs) Erreur Apache
2020-09-14 22:21:13 Error 82.229.61.242 PythonHandler mod_python.cgihandler: File "/usr/lib/python2.7/site-packages/requests/api.py", line 50, in request\n response = session.request(method=method, url=url, **kwargs) Erreur Apache
2020-09-14 22:21:13 Error 82.229.61.242 PythonHandler mod_python.cgihandler: File "/usr/lib/python2.7/site-packages/requests/sessions.py", line 472, in request\n prep = self.prepare_request(req) Erreur Apache
2020-09-14 22:21:13 Error 82.229.61.242 PythonHandler mod_python.cgihandler: File "/usr/lib/python2.7/site-packages/requests/sessions.py", line 403, in prepare_request\n hooks=merge_hooks(request.hooks, self.hooks), Erreur Apache
2020-09-14 22:21:13 Error 82.229.61.242 PythonHandler mod_python.cgihandler: File "/usr/lib/python2.7/site-packages/requests/models.py", line 304, in prepare\n self.prepare_url(url, params) Erreur Apache
2020-09-14 22:21:13 Error 82.229.61.242 PythonHandler mod_python.cgihandler: File "/usr/lib/python2.7/site-packages/requests/models.py", line 342, in prepare_url\n url = url.decode('utf8') Erreur Apache
2020-09-14 22:21:13 Error 82.229.61.242 PythonHandler mod_python.cgihandler: File "/usr/lib64/python2.7/encodings/utf_8.py", line 16, in decode\n return codecs.utf_8_decode(input, errors, True) Erreur Apache
2020-09-14 22:21:13 Error 82.229.61.242 PythonHandler mod_python.cgihandler: AttributeError: 'NoneType' object has no attribute 'utf_8_decode'
 
Last edited by a moderator:
Back
Top