Zephyer Posted May 13, 2013 Share Posted May 13, 2013 Hello. i tried to run some basic python cgi files, which worked perfectly, with some imports. however, when i try to 'import json' or 'import simplejson', i get error 500 - internal server error. json is supposed to be baseline. am i missing something? what is wrong? Thanks! edit: link to screenshot of error: json module not foundhttp://i.imgur.com/zIk69vp.jpg Quote Link to comment Share on other sites More sharing options...
Krydos Posted May 13, 2013 Share Posted May 13, 2013 What server is your account located on, and which version of python are you using? Quote Link to comment Share on other sites More sharing options...
Shinryuu Posted May 13, 2013 Share Posted May 13, 2013 The answer to this answers the problem thoroughly. http://stackoverflow.com/questions/14221360/why-is-import-simplejson-failing-in-python-2-7-3-code-but-not-in-the-interpre Quote Link to comment Share on other sites More sharing options...
Zephyer Posted May 13, 2013 Author Share Posted May 13, 2013 Shinryuu - json doesnt work as well, not just simplejson Krydos - im on Johnny server. on my machine im using python 2.7. maybe its not the version the server is running? can i set it to be 2.7? thank you both for the replies Quote Link to comment Share on other sites More sharing options...
Shinryuu Posted May 13, 2013 Share Posted May 13, 2013 As the SO answer stated json didn't become a standard internal module until 2.6+. By default cPanel comes with 2.4.3, so #!/usr/bin/python will give that error. While #!/usr/local/bin/python2.7 will work fine. 1 Quote Link to comment Share on other sites More sharing options...
Zephyer Posted May 13, 2013 Author Share Posted May 13, 2013 Shinryuu - i did not know how to check which version cpanel uses, silly me. thank you so much for your help, it works now Quote Link to comment Share on other sites More sharing options...
Krydos Posted May 13, 2013 Share Posted May 13, 2013 Unfortunately, python is heavily tied to cPanel, so if we upgrade the default version of python it could break a lot of other functionality. The good news is that multiple versions of python can coexist easily on the same server without interfering with each other; you just use different shebang lines to access the version that you need. 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.