Python "import cgi" not working (Python 2.7.1)

 
Post new topic   Reply to topic    Aprelium Forum Index -> FastCGI/CGI
View previous topic :: View next topic  
Author Message
bensing
-


Joined: 25 Mar 2011
Posts: 1

PostPosted: Fri Mar 25, 2011 6:10 pm    Post subject: Python "import cgi" not working (Python 2.7.1) Reply with quote

Hi,

I've recently installed Abyss Web Server, and followed the instructions to enable Python 2.7.1.

I've 2 scripts in my document root, random.py and python-cgi.py (I'm learning python, and am starting to use the cgi module python provides).

So in python-cgi.py, the lines of code goes as follows:
Code:
#!/Python-2.7.1/python
import cgi
...


However, upon accessing the file in my browser, it displays the contents of random.py, and nothing below the line "import cgi" is ever reached.

I have tried the following:

1) commented out the "import cgi" line and all lines requiring the cgi module; this results in the rest of python-cgi.py running normally

2) changing the shebang line to "#!/Python-2.7.1/python -u"; result is no difference

3) changing the arguments passed to the python interpreter in abyss web server; result is no difference

I would like to know if the problem can be resolved by changing a setting in Abyss Web Server.

This is the result of the cgi log file generated:
Code:
Traceback (most recent call last):
  File "python-cgi.py", line 3, in <module>
    import cgi
  File "C:\Python-2.7.1\lib\cgi.py", line 51, in <module>
    import mimetools
  File "C:\Python-2.7.1\lib\mimetools.py", line 6, in <module>
    import tempfile
  File "C:\Python-2.7.1\lib\tempfile.py", line 34, in <module>
    from random import Random as _Random
ImportError: cannot import name Random


Any help is appreciated. Thank you!
_________________
Benjamin
Back to top View user's profile Send private message MSN Messenger
aprelium-support
-


Joined: 20 Feb 2009
Posts: 356

PostPosted: Mon Mar 28, 2011 12:01 pm    Post subject: Reply with quote

random is a standard library in python you cannot use its name for your scripts. A random.py exists already in python.



Try to rename your random.py into random2.py for example and do another test.

We'll be waiting for your reply.
_________________
Support Team
Aprelium - http://www.aprelium.com
Back to top View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    Aprelium Forum Index -> FastCGI/CGI All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB phpBB Group