Reputation: 535
I've created a n new directory, a virtualenv and installed a django-toolbelt inside it. The django-version should be 1.8 but when I call 'django-admin.py version' it says 1.6. So when I start a new project it creates a 1.6. I thought virtualenv was supposed to prevent this. What am I doing wrong?
Edit: I think it has to do with the PATH (?). Like it's calling the wrong django-admin version. I'm on Windows 7. Still don't know how to fix it.
Upvotes: 1
Views: 2221
Reputation: 89
I had the same problem. Could be related to your zsh/bash settings.
I realized that using zsh (my default) I would get django-admin version 1.11 despite the Django version was 2.1! When I tried the same thing with bash I would get django-admin version 2.1 (the correct version). Certainly a misconfiguration.
So, I strongly suggest you check your zsh or bash settings to check for paths you might have.
Upvotes: 0
Reputation: 3389
I came across this problem too. In the official document, I found that, in a virtual environment, if you use the command 'django-admin'
, it would search from PATH usually in '/usr/local/bin'
(Linux) to find 'django-admin.py' which is a symlink to another version of django. This is the reason of what happened finally.
So there are two methods to solve this problem:
'python django-admin.py startproject project_name project_full_path'
to create django projectUpvotes: 3
Reputation: 8774
Try and install Django into the virtual environment as well:
pip install django
It should install the latest version, you can also specify a particular version (let's say 1.8.2) if you need to:
pip install django==1.8.2
Either way you'll have the correct version of Django in your virtual environment and it should work as you expect then.
You can also use the following command to see what version you have installed:
pip show django
Update:
It seems that you have the correct version installed in your virtual environment, but for some reason your Windows 7 use the system Django installation instead while you use manage.py
or django-admin.py
directly. However, you can use python manage.py
or python django-admin.py
instead, which seems to work as expected (and use the virtualenv Django installation).
Upvotes: 2
Reputation: 1063
Create a virtual environment for a project:
$ mkdir cd my_project_folder
$ cd my_project_folder
$ virtualenv venv
$ source venv/bin/activate
And now install django
(venv) ~$ pip install django==1.8
manage.py runserver in virtualenv using wrong django version
pip / virtualenv / django installation issue
Upvotes: -1