Reputation: 2797
I'm very new to Python, but want to run script from server. So, I have following structure
project
-A1
--A1.py
--A2.py
-B1
--B1.py
--B2.py
-test.py
Also there is __init__.py
in each subdirectory
In test.py I have simple code
#!/usr/bin/python
print "Content-type: text/html\n\n"
print 'A'
from project import *
print 'B'
But B
is not shown on page.
Maybe I do something wrong with import?
Note, that I copied files, instead of installing them. Maybe this is the reason? Maybe I should add something into system path? I don't want to install, because in future I will need to change those files.
Maybe problem is in file persmissions. I had 644 and changed to 755, but that doesn't help.
Thank you in advance.
Upvotes: 0
Views: 4318
Reputation: 174624
Since your script doesn't complete successfully, (it raises an exception because sympy isn't installed), you do not see any output on the browser because the request doesn't complete.
If you were to check your server's error logs, you will see entries there reflecting this.
To fix the problem, install sympy - then make sure your script runs without errors from the command line, and only then access it from the browser.
Upvotes: 1
Reputation: 64318
Check sys.stdout
before and after the import.
Also, try calling sys.stdout.flush()
after the second print line.
Upvotes: 0