• Our team is looking to connect with folks who use email services provided by Plesk, or a premium service. If you'd like to be part of the discovery process and share your experiences, we invite you to complete this short screening survey. If your responses match the persona we are looking for, you'll receive a link to schedule a call at your convenience. We look forward to hearing from you!
  • We are looking for U.S.-based freelancer or agency working with SEO or WordPress for a quick 30-min interviews to gather feedback on XOVI, a successful German SEO tool we’re looking to launch in the U.S.
    If you qualify and participate, you’ll receive a $30 Amazon gift card as a thank-you. Please apply here. Thanks for helping shape a better SEO product for agencies!
  • The BIND DNS server has already been deprecated and removed from Plesk for Windows.
    If a Plesk for Windows server is still using BIND, the upgrade to Plesk Obsidian 18.0.70 will be unavailable until the administrator switches the DNS server to Microsoft DNS. We strongly recommend transitioning to Microsoft DNS within the next 6 weeks, before the Plesk 18.0.70 release.
  • The Horde component is removed from Plesk Installer. We recommend switching to another webmail software supported in Plesk.

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