0

I'm trying to use a new version of Django (1.9). I've created a virtual environment (venv) in which I've installed new Django (1.9). Everything seems to work correctly but when I do manage.py runserver it seems that it uses older version of Django (1.8.7).

My venv is activated so I don't know why it behaves this way.

I'm attaching cmd commands from scratch: enter image description here

Do you know where is the problem?

Milano
  • 18,048
  • 37
  • 153
  • 353

2 Answers2

6

I guess manage.py uses system-wide python executable: look at its shebang (first line). Try running python manage.py ...

Eugene Primako
  • 2,767
  • 9
  • 26
  • 35
  • Thanks, it works. But do I have to write python before each command? – Milano Jan 01 '16 at 16:56
  • This script has a shebang (first line indicating what program this script will be run with). So when you run it as stand-alone executable - the system-wide python is used. Thats why you need to run python manage.py, not manage.py. – Eugene Primako Jan 01 '16 at 16:58
  • This is WIndows. The shebang doesn't work, but `.py` will be associated to the system Python install. When you `activate`, your `%PATH%` is updated to use the virtualenv Python. You will have to use `python manage.py`. – Alastair McCormack Jan 01 '16 at 17:00
  • The shebang line works on windows from py3.3 with the python launcher. How can it otherwise be that the manage.py call works? Before py3.3 you needed to call it with python, but now it should work with the shebang. – rfkortekaas Jan 01 '16 at 17:25
  • 1
    Two suggestions for Windows development (I support a team that has Mac, Windows and Linux developers): use virtualenvwrapper-win, it will make your life much easier: https://pypi.python.org/pypi/virtualenvwrapper-win Also, you may want to look into using git-bash with the MinGW shell, it is much nicer than cmd.exe: https://git-for-windows.github.io/ Just my two cents, they've made my development life on Windows MUCH nicer! – FlipperPA Jan 01 '16 at 23:45
2

The shebang line in the manage.py points to the global installed python. If you change it to the venv python it should work as used normally.

rfkortekaas
  • 6,049
  • 2
  • 27
  • 34