Getting 'ImportError: No module named tornado.httpserver'

3,049 views
Skip to first unread message

qliq

unread,
Oct 8, 2013, 3:26:49 AM10/8/13
to python-...@googlegroups.com

Hi everybody,

I'm tying to deploy a simple tornado app on my Debian 6 server. I've installed tornado using pip and now it is on:

/usr/local/lib/python2.6/dist-packages/tornado

Also I added manually the path to tornado on .bashrc of myuser who executes myapp.py:

PYTHONPATH=/usr/local/lib/python2.6/dist-packages/tornado:/usr/local/lib/python2.6/dist-packages/tornado:/usr/local/lib/python2.6/dist-packages

myuser is member of www-data group.

I get this annoying error in /var/log/tornado.log:

File "/path/to/myapp.py", line 1, in <module>
    import tornado.httpserver, tornado.ioloop, tornado.options, tornado.web, os.path, random, string
ImportError: No module named tornado.httpserver

The supervisor.conf is like this:

[group:tornadoes]
programs=tornado-8000,tornado-8001,tornado-8002,tornado-8003


[program:tornado-8000]
command=python /path/to/myapp.py --port=8000
directory=/path/to
user=www-data
autorestart=true
redirect_stderr=true
stdout_logfile=/var/log/tornado.log
loglevel=info
[program:tornado-8001]
command=python /path/to/myapp.py --port=8001
directory=/path/to
user=www-data
autorestart=true
redirect_stderr=true
stdout_logfile=/var/log/tornado.log
loglevel=info
[program:tornado-8002]
command=python /path/to/myapp.py --port=8002
directory=/path/to
user=www-data
autorestart=true
redirect_stderr=true
stdout_logfile=/var/log/tornado.log
loglevel=info
[program:tornado-8003]
command=python /path/to/myapp.py --port=8003
directory=/path/to
user=www-data
autorestart=true
redirect_stderr=true
stdout_logfile=/var/log/tornado.log
loglevel=info

strangely enough, the very same app with the same configs (apart form /path/to/myapp.py and file owner) was deployed fine on another Debian test server. Really got confused and appreciate your hints.

Thanks


aliane abdelouahab

unread,
Oct 8, 2013, 8:38:53 AM10/8/13
to python-...@googlegroups.com
when you start a simple python console, will tornado be imported?
if it will be  imported, then get the location by making tornado.__path__

Ben Darnell

unread,
Oct 8, 2013, 8:43:39 AM10/8/13
to Tornado Mailing List
On Tue, Oct 8, 2013 at 3:26 AM, qliq <esi...@gmail.com> wrote:

Hi everybody,

I'm tying to deploy a simple tornado app on my Debian 6 server. I've installed tornado using pip and now it is on:

/usr/local/lib/python2.6/dist-packages/tornado

Also I added manually the path to tornado on .bashrc of myuser who executes myapp.py:


PYTHONPATH=/usr/local/lib/python2.6/dist-packages/tornado:/usr/local/lib/python2.6/dist-packages/tornado:/usr/local/lib/python2.6/dist-packages


You shouldn't add the tornado directory to PYTHONPATH, but the directory that contains it (dist-packages).  I'm not sure how debian sets up its default python path, but directories like dist-packages and site-packages are usually on it by default.  If they're not, you actually need to add them via a sitecustomize.py file (using site.addsitedir()) instead of just modifying the pythonpath for certain features to work (although this doesn't matter for tornado).
 

myuser is member of www-data group.

I get this annoying error in /var/log/tornado.log:


File "/path/to/myapp.py", line 1, in <module>
    import tornado.httpserver, tornado.ioloop, tornado.options, tornado.web, os.path, random, string
ImportError: No module named tornado.httpserver

The supervisor.conf is like this:


.bashrc is not used when running a program under supervisord.  If you need to change the environment, do so with an 'environment' statement in supervisor.conf.
 

--
You received this message because you are subscribed to the Google Groups "Tornado Web Server" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python-tornad...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply all
Reply to author
Forward
0 new messages