Wrong Python version when using Virtualenv in pythonanywhere
To use Pyhton 3.3 and django 1.8 im using Virtualenv (for web app in pythonanywhere
)
I followed the instructions below: https://www.pythonanywhere.com/wiki/VirtualEnvForNewerDjango
Going to the console shows that I am using version 3.3
(django18)12:04 ~ $ python
Python 3.3.6 (default, Jan 28 2015, 17:27:09)
[GCC 4.8.2] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>
Which version I also want to specify in my web app:
Python version:3.3 (in the code pane)
However, when I point in the Virtualenv area to the Virtualenv directory (named django18), I get the following warning:
This virtualenv seems to have the wrong Python version (2.7 instead of 3.3).
Here is the entire console (I started it after building the application and specifying the Python version):
06:43 ~ $ mkvirtualenv --python=/usr/bin/python3.3 django18
Running virtualenv with interpreter /usr/bin/python3.3
Using base prefix '/usr'
New python executable in django18/bin/python3.3
Not overwriting existing python script django18/bin/python (you must use django18/b
in/python3.3)
Installing setuptools, pip, wheel...done.
(django18)06:44 ~ $ which pip
/home/yschellekens/.virtualenvs/django18/bin/pip
(django18)06:44 ~ $ pip install django
Requirement already satisfied (use --upgrade to upgrade): django in ./.virtualenvs/
django18/lib/python3.3/site-packages
(django18)06:44 ~ $ which django-admin.py
/home/yschellekens/.virtualenvs/django18/bin/django-admin.py
(django18)06:44 ~ $ django-admin.py --version
1.8.3
(django18)06:44 ~ $ django-admin.py startproject mysite
CommandError: '/home/yschellekens/mysite' already exists
Also see:
08:29 ~/.virtualenvs/django18/bin $ ls
__pycache__ django-admin.py pip postdeactivate python3
activate django-admin.pyc pip2 preactivate python3.3
activate.csh easy_install pip2.7 predeactivate wheel
activate.fish easy_install-2.7 pip3 python
activate_this.py easy_install-3.3 pip3.3 python2
django-admin get_env_details postactivate python2.7
08:29 ~/.virtualenvs/django18/bin $
My question is, where else should I be pointing to Python 3.3?
Thanks in advance!
source to share
It seems to me that your virtualenv somehow got both version 2.7 and 3.3 of Python in it. Try to remove it and recreate it:
rmvirtualenv django18
mkvirtualenv --python=/usr/bin/python3.3 django18
pip install django # reinstall django and any other packages you need.
Why not use Python 3.4 by the way?
source to share
Don't overwrite existing python script django18 / bin / python
Since you build env with python 2.7 and then with python 3.3, the django18 / bin / python script still points to python 2.7. Change django18/bin/python
or remove env and use the command mkvirtualenv --python=/usr/bin/python3.3 django18
.
Old answer:
From the link you provided:
TIP: if you want to use Python 3 for your virtual user, use mkvirtualenv --python = / usr / bin / python3.4 django18
https://www.pythonanywhere.com/wiki/VirtualEnvForNewerDjango
source to share