Jump to content

Python 2.7 Module Request/500 Error Troulbeshooting


silverx

Recommended Posts

Hi everyone,

i have just tried to launch a python script but it trows the infamous 500 Error.

I think there might be some module missing from the server. Here is what i need:

 

Server: Johnny

User: silverb

Python Version: 2.7

 

Modules:

- __future__ for the print_function

- os

- json

- time

 

The baffling fact is that these modules should come with a "default" python installation, so i'm not sure if this is the problem. I would also need the httplib2, google api client and oauth2 module, but i read that they are already present in johnny's python 2.7.

 

Apart from a possible module missing, could there be some problem with reading a file from the current work directory or creating a folder and a file?

 

Thank you for your support and your time.

Edited by silverx
Link to comment
Share on other sites

The baffling fact is that these modules should come with a "default" python installation,

The modules that come with a default python are not included on the list because they are guaranteed to be there. The list is for installed modules only.

# /usr/bin/python2.7
Python 2.7.13 (default, Aug 25 2017, 20:17:53)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-18)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import os
>>> import json
>>> import time
>>> import httplib2
>>> import googleapiclient
>>> import oauth2client
>>> from __future__ import print_function
>>> import not_a_module
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named not_a_module
None of your imports are causing the 500 error. The final not_a_module is to show what it would look like if any of those imports were the issue.

 

Here's a way to debug your script:

  • Go to https://johnny.heliohost.org:2083/frontend/paper_lantern/cron/index.html
  • Type in an email address that you would like to receive the error report at
  • Click update email
  • Go to https://www.google.com/search?q=current+time+in+pst
  • Pick a time roughly 5 minutes in the future to give you time to finish the rest of this tutorial
  • Type the minutes (example: 5 for 2:05pm)
  • Type in the hour in 24 hour format (example: 14 for 2:05pm)
  • Put * in the next three boxes, day, month, weekday
  • In command put your shebang without the leading #! (example: /usr/bin/python2.7)
  • Followed by a space and then the absolute path to your script that is throwing a 500 error (example: /home/silverb/public_html/DFArchiver.py)
  • Click Add New Cron Job
  • Wait until the time that you set your cron job to run and then check your email
  • If you got an email be sure to click delete next to your cron under the Current Cron Jobs header to make sure you don't exceed your 2 per day limit
Here is an example email I just got:

Date: Sun, 03 Sep 2017 08:06:02 -0700
X-AntiAbuse: This header was added to track abuse, please include it with any abuse report
X-AntiAbuse: Primary Hostname - johnny.heliohost.org
X-AntiAbuse: Original Domain - yahoo.com
X-AntiAbuse: Originator/Caller UID/GID - [503 498] / [47 12]
X-AntiAbuse: Sender Address Domain - johnny.heliohost.org
X-Get-Message-Sender-Via: johnny.heliohost.org: authenticated_id: krydos2/primary_hostname/system user
X-Authenticated-Sender: johnny.heliohost.org: krydos2
X-Source: 
X-Source-Args: CROND 
X-Source-Dir: /home/krydos2
Content-Length: 136

  File "/home/krydos2/public_html/cgi-bin/test.py", line 6
    
                            ^
SyntaxError: unexpected EOF while parsing
Sure enough line 6 is

print("Heliohost rules!"
It's (intentionally) missing the closing parenthesis.
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...