Flask+Nginx+uWSGI : ImportError: No module named site

给你一囗甜甜゛ 提交于 2019-12-05 09:21:40

Here's how I resolved the same error message (ImportError: No module named site) that I got while trying the Django and NGINX tutorial — uWSGI 2.0 documentation.

Deactivate the virtualenv:

deactivate

Install uWSGI system-wide (if not already installed system-wide)

sudo pip install uwsgi

Edit the uwsgi.ini file. I commented out the line with the:

home = /path/to/virtualenv

Run uWSGI --ini mysite_uwsgi.ini.

I read a lot of document about the question, but get no answer.

By coincidentally, I fix this problem by edit uid and gid as root.

It seem like a permissions problem. I don't know why, but it just work. Remember, it is very unsafe to run a product environment as root.

1、active the virtual you used

2、 pip install uwsgi

this the key action,then the

command -v wsgi

show this

/virtual-path/bin/uwsgi

3、use current user to run uwsgi, because other user is not active the virtualenv

Im My case I wasn't using virtualEnv. Just using django + ngnix. My solution was removing HOME variable into the *.ini configuration file:

sudo nano /etc/uwsgi/sites/c_app.ini

[uwsgi]
    project = c_app
    uid = ubuntu
    base = /home/%(uid)

    chdir = %(base)/%(project)
    **home = %(base)/%(project)** (REMOVED IT)
    module = %(project).wsgi:application

    master = true
    processes = 5

    socket = /run/uwsgi/%(project).sock
    chown-socket = %(uid):www-data
    chmod-socket = 660
    vacuum = true

then it works.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!