I am learning Django and in Command Prompt I have already installed Django, then when I check django-admin --version
it says 'django-admin' is not recognized as an internal or external command, operable program or batch file.
Because of this I tried to install Django 3 times again but it still output the same.
What is the cause of this problem?
To test is my Django is working or not I have also tried to import django
in my python interpreter. I have 2 python versions in my computer the first one is 3.8 and the second one is 3.8.6 ,which the CMD tells me to download. When I tried to import django
in python3.8 it output No module named 'django'
, when I tried to import django
in python3.8.6 it worked !! I hope my python 3.8 work because my Pycharm is using that.
You should use the python version set for the virtual environment. When creating a virtual environment specify the python version or it will use a default one which may not be the desired one:
whereis python
This would return a result similar to:
python: /usr/bin/python3.6-config /usr/bin/python3.6 /usr/bin/python3.6m /usr/bin/python2.7-config /usr/bin/python /usr/bin/python3.6m-config /usr/bin/python2.7 /usr/lib/python3.6 /usr/lib/python3.8 /usr/lib/python2.7 /usr/lib/python3.7 /etc/python3.6 /etc/python /etc/python2.7 /usr/local/lib/python3.6 /usr/local/lib/python2.7 /usr/include/python3.6 /usr/include/python3.6m /usr/include/python2.7 /usr/share/python /usr/share/man/man1/python.1.gz
And I create the virt env with this:
virtualenv -p /usr/bin/python3.6 djangoTut
There are other ways to create virt env. You could also use virtualenvwrapper
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.