Reputation: 20810
This is puzzling, because uWSGI works when running:
uwsgi --http :8003 --wsgi-file bigsky.wsgi
But doesn't work with:
uwsgi --ini uwsgi.ini --no-site
It returns this error:
Traceback (most recent call last):
File "bigsky.wsgi", line 1, in <module>
import os
ImportError: No module named os
This is being deployed with:
Here's the code:
uwsgi.ini:
[uwsgi]
# %d is the dir this configuration file is in
socket = 127.0.0.1:8003
chmod-socket = 666
uid = bsdev
gid = bsdev
master = true
enable-threads = true
processes = 4
# virtualenv
home = /home/bsdev/.virtualenvs/bs_py34
chdir = /www/django/releases/persistent/bsrs/python3/
wsgi-file = project.wsgi
env = DJANGO_SETTINGS_MODULE=project.settings.persistent
# create a pidfile
pidfile = /tmp/project-master.pid
harakiri = 10 # respawn processes taking more than 20 seconds
max-requests = 5000 # respawn processes after serving 5000 requests
# will be run via `supervisord` so don't need to daemonize
# logto = /var/log/uwsgi/project.log
logdate = true
vacuum = true
project.wsgi:
import os
import sys
# python 3
sys.path.append('/usr/local/bin/python3.4')
sys.path.append('/usr/local/lib/python3.4/site-packages')
# project
sys.path.append('/www/django/releases/persistent/bsrs/python3')
sys.path.append('/www/django/releases/persistent/bsrs/bsrs-django')
sys.path.append('/www/django/releases/persistent/bsrs/bsrs-django/project')
sys.path.append('/www/django/releases/persistent/bsrs/bsrs-django/project/project')
# 1st instantiate wsgi
from django.core.wsgi import get_wsgi_application
_application = get_wsgi_application()
# Add the app directories to the PYTHONPATH
os.environ['DJANGO_SETTINGS_MODULE'] = 'project.settings.persistent'
def application(environ, start_response):
return _application(environ, start_response)
Edit:
I am also getting this error message. It says Python version: 2.7.5, but the Django App should be running in python 3.4. Is this a possible issue?
Tue Sep 22 13:25:12 2015 - thunder lock: disabled (you can enable it with --thunder-lock)
Tue Sep 22 13:25:12 2015 - uwsgi socket 0 bound to UNIX address /tmp/bigsky.sock fd 3
Tue Sep 22 13:25:12 2015 - Python version: 2.7.5 (default, Jun 24 2015, 00:41:19) [GCC 4.8.3 20140911 (Red Hat 4.8.3-9)]
Tue Sep 22 13:25:12 2015 - Set PythonHome to /home/bsdev/.virtualenvs/bs_py34/
Tue Sep 22 13:25:12 2015 - Python main interpreter initialized at 0x25258f0
Tue Sep 22 13:25:12 2015 - python threads support enabled
Tue Sep 22 13:25:12 2015 - your server socket listen backlog is limited to 100 connections
Tue Sep 22 13:25:12 2015 - your mercy for graceful operations on workers is 60 seconds
Tue Sep 22 13:25:12 2015 - mapped 363840 bytes (355 KB) for 4 cores
Tue Sep 22 13:25:12 2015 - *** Operational MODE: preforking ***
Traceback (most recent call last):
File "./bigsky/wsgi.py", line 1, in <module>
import os
ImportError: No module named os
Upvotes: 1
Views: 2941
Reputation: 315
You are using python3, so install uwsgi
with pip3
pip3 install uwsgi
Upvotes: 2
Reputation: 20810
I was having this issue, because I had not compliled uWSGI correctly on Centos 7, and needed to then build it with Python 3.4. In short, here are the commands:
wget http://projects.unbit.it/downloads/uwsgi-2.0.3.tar.gz
tar -xvf uwsgi-2.0.3.tar.gz
cd uwsgi-2.0.3
source ~/path/to/virtualenv_python3.4/bin/activate
python uwsgiconfig.py --build
Then run uWSGI:
sudo ~/misc/uwsgi-2.0.3/uwsgi --ini uwsgi.ini
Upvotes: 2