简体   繁体   中英

django app on server: I moved from python 2.7 to 3.5 and apache2 can't find django

I have a Django (v1.11.6) app on my Ubuntu server and was using Python v2.7.

I am now using Python 3.5 (not using virtualenv ), however when I run sudo service apache2 restart I get the following error:

[Mon Oct 23 12:50:22.001339 2017] [wsgi:error] [pid 28871] [client 194.42.16.145:28999]     from django.core.wsgi import get_wsgi_application
[Mon Oct 23 12:50:22.001360 2017] [wsgi:error] [pid 28871] [client 194.42.16.145:28999] ImportError: No module named 'django'

When I run python3 manage.py runserver I get no error.

Install Django into your Python 3 environment. Run:

pip3 install django

or

pip install virtualenv
virtualenv --python=python3 mynewenv
source mynewenv/bin/activate
pip install django

or

sudo apt-get install python3-django

[Based on Daniel Roseman comment]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM