I have installed django==3.1.4 and activated Venv on my windows machine and it works fine in myBlog project. But today when I try to run the server, got this 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?
but venv is already activated and when I do pip freeze > requirements.txt
It shows
asgiref==3.3.4,
Django==3.1.4,
django-crispy-forms==1.11.2,
Pillow==8.2.0,
pytz==2021.1,
sqlparse==0.4.1,
I also checked sys.path
, It shows
['', 'C:\Users\user\AppData\Local\Programs\Python\Python38-32\python38.zip', 'C:\Users\user\AppData\Local\Programs\Python\Python38-32\DLLs', 'C:\Users\user\AppData\Local\Programs\Python\Python38-32\lib', 'C:\Users\user\AppData\Local\Programs\Python\Python38-32', 'C:\Users\user\Desktop\myBlog\venv', 'C:\Users\user\Desktop\myBlog\venv\lib\site-packages']
Please Help to fix this
if you are trying to run the django server from within your IDE makesure that your virtual environment is active inside the IDE as well.
thanks, everybody..problem fixed..probably occurred because I did some C drive repair
I got following error
ModuleNotFoundError: No module named 'django'
I did the following steps.. to overcome my error:
pip freeze > requirements.txt
, if it saves all your packages then only do other stepspip install -r requirements.txt
this will install all your packages back.python manage.py runserver
, It will work fine
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.