Search code examples
pythonapachejson2html

Why am I getting an Internal Server error


My python script runs just fine on the Apache server locally set up on my computer, however, on importing the json2html library I am getting an internal server error

The moment I comment the import statement out , it seems to work. I even tried importing just the functions from the library , thinking maybe it is a space constraint or so.

 #!/usr/bin/python
import cgi,cgitb
 #import json2html#this has the errir
import cassandra
from cassandra.cluster import Cluster
from cassandra.auth import PlainTextAuthProvider

Internal Server Error

From logs: ImportError: No module named json2html [Tue Jun 11 15:42:52.495135 2019] [cgid:error] [pid 2235:tid 140698967865088] [client 127.0.0.1:35474] End of script output before headers: show.py, referer: http://test.com/ Traceback (most recent call last): File "/home/arjun/Cassandra/website_test/show.py", line 6, in from json2html import *

The module works fine on my system and dosen't give any errors,but it seems to have a problem when running on the server.

Can somebody help fix this?


Solution

  • The server may be running under a different user. In that case, you may have installed json2html in a location that the Apache server user cannot access.

    To check this, run a small script that prints sys.version both locally and in the server. If there is a mismatch, then try installing json2html either:

    • under the Apache server user
    • system-wide using pip