简体   繁体   中英

uwsgi + django import error

I have a problem when I use django with uwsgi with the pythonpath.

I have a django project named 'project' which is the /sites/django/ directory

So to start uwsgi i use this command :

/opt/uwsgi/uwsgi -s 127.0.0.1:9001 -C -M 4 -t 30 -A 4 -p 4 -d /var/log/uwsgi.log --pythonpath '/sites/django/project/' --module wsgi

If I am in the /sites/django/project' it works.

If I start a python shell and I write :

import sys
sys.path.append('/sites/django/project/')
import wsgi

It works too.

But when i launch the uwsgi command outside the /sites/django/project/ I have the error :

ImportError: No module named wsgi

So I don't know why I have the ImportError : it works in the shell.

If anyone has an idea, Thanks.

Well, i find the answer, it seems it's a bug and i must add the "-i" option (single interpreter mode ) in my command .

The documentation seems to suggest two possibilities.

First, remove the single quotes from the python path argument. Second, the examples on the linked page have --python-path instead of --pythonpath (even though the index at the top of the page says otherwise). Worth trying.

如果您使用的是virtualenv,则需要传递-H标志( http://projects.unbit.it/uwsgi/wiki/VirtualEnv

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM