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

I installed as http://www.reinbach.com/uwsgi-nginx-flask-virtualenv-mac-os-x.html and when executing the uwsgi --ini deploy/deploy.ini terminal says that an import error has occurred :

Install PYTHONHOME in /virtualenv/sample/

 ImportError: No module named site 

I set my PYTHONHOME and PYTHONPATH as

 export PYTHONPATH=$PYTHONPATH:/Library/Python/2.7/site-packages export PYTHONHOME=$PYTHONHOME:/Library/Python/2.7 

I canโ€™t understand whatโ€™s wrong with him.

Can someone help me with a problem?

All information in the terminal is shown below, if useful:

 (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)] 

Install PYTHONHOME in /virtualenv/sample/

 ImportError: No module named site 
+5
source share
4 answers

This is how I solved the same error message (ImportError: No module named site) received while trying to study the Django and NGINX manual - uWSGI 2.0 documentation .

Deactivate virtualenv:

 deactivate 

Install uWSGI for the entire system (if it is not already installed for the entire system)

 sudo pip install uwsgi 

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

 home = /path/to/virtualenv 

Run uWSGI --ini mysite_uwsgi.ini .

+8
source

I read a lot of the document about this question, but did not receive an answer.

Coincidentally, I fix this problem by editing uid and gid as root.

This seems like a permission issue. I donโ€™t know why, but it just works. Remember that it is very dangerous to run a product environment with root privileges.

+1
source

1, the virtual one you are using is active

2, pip install uwsgi

this is a key action then

 command -v wsgi 

show it

 /virtual-path/bin/uwsgi 

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

0
source

In my case, I did not use virtualEnv. Just using django + ngnix. My solution was to delete the HOME variable in 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.

0
source

Source: https://habr.com/ru/post/983486/


All Articles