Flask + Nginx + uWSGI:ImportError:没有名为site的模块

Yuq*_*uqi 5 python nginx flask uwsgi

我安装了http://www.reinbach.com/uwsgi-nginx-flask-virtualenv-mac-os-x.html链接的教程,在执行命令时uwsgi --ini deploy/deploy.ini,终端说出现了导入错误:

设置PYTHONHOME/virtualenv/sample/

ImportError: No module named site
Run Code Online (Sandbox Code Playgroud)

我已经把我PYTHONHOMEPYTHONPATH

export PYTHONPATH=$PYTHONPATH:/Library/Python/2.7/site-packages
export PYTHONHOME=$PYTHONHOME:/Library/Python/2.7
Run Code Online (Sandbox Code Playgroud)

我无法弄清楚它有什么问题.

有人可以帮我解决这个问题吗?

如果有用,终端中的整个信息如下所示:

(env)ios-devmatoMacBook-Pro:hello ios_dev$ uwsgi --ini deploy/deploy.ini
[uWSGI] getting INI configuration from deploy/deploy.ini
*** Starting uWSGI 1.9.10 (64bit) on [Fri May 17 16:42:22 2013] ***
compiled with version: 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2336.11.00) on 17 May 2013 12:41:07
os: Darwin-11.4.2 Darwin Kernel Version 11.4.2: Thu Aug 23 16:25:48 PDT 2012; root:xnu-
1699.32.7~1/RELEASE_X86_64
nodename: ios-devmatoMacBook-Pro.local
machine: x86_64
clock source: unix
detected number of CPU cores: 4
current working directory: /Users/ios_dev/Desktop/sample/hello
detected binary path: /Users/ios_dev/Documents/little/little-web/little_web_dev/env/bin/uwsgi
your processes number limit is 709
your memory page size is 4096 bytes
detected max file descriptor number: 256
lock engine: OSX spinlocks
uwsgi socket 0 bound to TCP address 127.0.0.1:3031 fd 3
Python version: 2.7.1 (r271:86832, Jun 16 2011, 16:59:05)  [GCC 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2335.15.00)]
Run Code Online (Sandbox Code Playgroud)

设置PYTHONHOME/virtualenv/sample/

ImportError: No module named site
Run Code Online (Sandbox Code Playgroud)

小智 8

以下是我在尝试本教程时解决的相同错误消息(ImportError:No module named site)的方法:https://uwsgi.readthedocs.org/en/latest/tutorials/Django_and_nginx.html.

  • 停用virtualenv
  • 在系统范围内安装uWSGI(如果尚未在系统范围内安装)

sudo pip install uwsgi

  • 编辑uwsgi.ini文件.我用这句话评论了这句话

home =/path/to/virtualenv

  • uWSGI --ini mysite_uwsgi.ini

  • 我不知道你为什么要删除home指令.这绝对不是正确的答案.home指令告诉uwsgi使用哪个virtualenv.因此,如果您不使用虚拟环境,则只能将其删除.ImportError通常意味着它无法在定义的virtualenv中找到模块,因此请确保它存在并且模块实际存在. (2认同)