Question
Usinv virtualenv in django image?
Hello!
I’ve used Django on Ubuntu image to create my droplet and it all worked well until I’ve tried to use virtualenv for django_project dependencies.
I’ve created home/django/venvs dir. Within it I’ve created venv that I have installed my app’s dependencies to.
Then I’ve edited upstart file to following:
description "Gunicorn daemon for Django project"
start on (local-filesystems and net-device-up IFACE=eth0)
stop on runlevel [!12345]
# If the process quits unexpectadly trigger a respawn
respawn
setuid django
setgid django
chdir /home/django
script
source venvs/myapp/bin/activate
end script
exec gunicorn \
--name=django_project \
--pythonpath=django_project \
--bind=0.0.0.0:9000 \
--config /etc/gunicorn.d/gunicorn.py \
django_project.wsgi:application
However Gunicorn fails to start app, which crashes on import of module thats in venv, but not in global python.
Question is what I am doing wrong? How to make default django_project use venv?
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.
×
I am having this same trouble now, any luck in solving it?