When running the command:
python manage.py runserver
To launch a test server, I get the following error:
ImportError: Couldn't import Django. Are you sure it's installed and available on your PYTHONPATH environment variable? Did you forget to activate a virtual environment?
Steps I took to get this error:
1) I downloaded the Django project from my Linux VPS (without the virtual environment). I am using Windows 10 on this current system.
2) I created a new virtual environment in that folder using:
virtualenv myprojectenv
3) The env was created successfully, I now have the following folders/files:
myproject myprojectenv static manage.py
4) I activate the env ( myprojectenv\\scripts\\activate
), success - my commandline changes to
(myprojectenv) C:\\ (path to my folder)
5) I install Django using
pip install django
Django successfully installed, when checking the version, it returns 2.1.1:
python -c "import django; print(django.get_version())
2.1.1
6) I go back to the main dir where manage.py is, I try to run the test server with
python manage.py runserver
And I get the error (specified above). So, what have I done wrong here? I have the env folder correctly in that directory, Django installed. It still can't find it.
I thought the problem may be with my Django files, but no. When I start a new project from the myprojectenv env using
django-admin startproject mysite
The mysite folder gets created - I go into that folder (where manage.py is) and I try to launch the test server again. It still can't find Django! Any help is appreciated.
--- make all of them in order
virtualenv example
source example/bin/activate
cd example
pip install django
django-admin.py startproject mysite
cd mysite
python manage.py runserver
--It have to work 100%
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.