• Debian 11 is approaching its end-of-life (vendor EOL date - August 31, 2026). Plesk Obsidian 18.0.80 will be the last release to support it.
    If you are running Plesk Obsidian on Debian 11, we recommend you upgrade those servers to Debian 12 using our dist-upgrade tool.
  • We plan to deprecate and remove the support for XML RPC protocol versions earlier than 1.6.9.1 in Plesk Obsidian 18.0.82. We strongly recommend that you update all existing integrations using earlier versions of the XML RPC protocol to comply with the version 1.6.9.1 specification.

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