Reputation: 3
I'm having allot of trouble getting python 2.7.5 to work on my CentOS7 server. Testing prints is not an issue but when I'm trying to import requests it breaks. I don't understand te error_log. I don't know what to do now. Please help :)
Yes requests is installed, I triple checked.
My code:
import requests
Result:
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>500 Internal Server Error</title>
</head><body>
<h1>Internal Server Error</h1>
<p>The server encountered an internal error or
misconfiguration and was unable to complete
your request.</p>
<p>Please contact the server administrator at
root@localhost to inform them of the time this error occurred,
and the actions you performed just before this error.</p>
<p>More information about this error may be available
in the server error log.</p>
</body></html>
Error_log:
[Mon Jan 21 20:11:54.179538 2019] [:error] [pid 16293] [client 84.85.100.198:32770] PythonHandler mod_python.cgihandler: Traceback (most recent call last):
[Mon Jan 21 20:11:54.179578 2019] [:error] [pid 16293] [client 84.85.100.198:32770] PythonHandler mod_python.cgihandler: File "/usr/lib64/python2.7/site-packages/mod_python/apache.py", line 398, in HandlerDispatch\n result = obj(req)
[Mon Jan 21 20:11:54.179586 2019] [:error] [pid 16293] [client 84.85.100.198:32770] 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)
[Mon Jan 21 20:11:54.179592 2019] [:error] [pid 16293] [client 84.85.100.198:32770] PythonHandler mod_python.cgihandler: File "/var/www/vhosts/vps-139083-2773.hosted.at.hostnet.nl/regt/test.py", line 23, in <module>\n import requests
[Mon Jan 21 20:11:54.179598 2019] [:error] [pid 16293] [client 84.85.100.198:32770] PythonHandler mod_python.cgihandler: File "/usr/lib/python2.7/site-packages/requests/__init__.py", line 53, in <module>\n from .packages.urllib3.contrib import pyopenssl
[Mon Jan 21 20:11:54.179605 2019] [:error] [pid 16293] [client 84.85.100.198:32770] PythonHandler mod_python.cgihandler: File "/usr/lib/python2.7/site-packages/requests/packages/__init__.py", line 61, in load_module\n if name in sys.modules:
[Mon Jan 21 20:11:54.179628 2019] [:error] [pid 16293] [client 84.85.100.198:32770] PythonHandler mod_python.cgihandler: AttributeError: 'NoneType' object has no attribute 'modules'
Upvotes: 0
Views: 896
Reputation: 3
Thanks to Benton Snyder i fixed the problem.
pip install --upgrade requests
din't work but i had to manualy remove the requests dir and then restart my server.
After that i reinstalled via pip install requests
Upvotes: 0
Reputation: 166
You appear to be using an older version of requests.
Unless you have a reason not to, try to upgrade requests to latest:
$ pip install --upgrade requests
Upvotes: 0