[英]wrong Python version when using Virtualenv in pythonanywhere
In order to use Pyhton 3.3 & django 1.8, im using Virtualenv (for a web app in pythonanywhere
) 为了使用Pyhton 3.3&DJANGO 1.8,使用VIRTUALENV IM(用于在web应用程序
pythonanywhere
)
I followed the following instructions: https://www.pythonanywhere.com/wiki/VirtualEnvForNewerDjango 我按照以下说明操作: https : //www.pythonanywhere.com/wiki/VirtualEnvForNewerDjango
Going into the console, shows that i'm using version 3.3 进入控制台,显示我使用的是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 is also the version i specified i want to use in my web app: 这也是我想要在我的网络应用中使用的版本:
Python version:3.3 (in the code pane)
However, when i point in the Virtualenv pane to the Virtualenv directory (named django18), i get the following warning: 但是,当我将Virtualenv窗格指向Virtualenv目录(名为django18)时,我收到以下警告:
This virtualenv seems to have the wrong Python version (2.7 instead of 3.3).
Here is all of the console (I've ran it after creating the application and specifying the Python version): 这是所有控制台(我在创建应用程序并指定Python版本后运行它):
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 point to Python 3.3? 我的问题是:我应该在哪里指向Python 3.3?
Thanks in advance! 提前致谢!
It looks to me like your virtualenv has somehow got both version 2.7 and version 3.3 of Python in it. 在我看来,你的virtualenv在某种程度上得到了Python的2.7版本和3.3版本。 Try deleting it and re-creating 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? 为什么不顺便使用Python 3.4?
Not overwriting existing python script django18/bin/python
不覆盖现有的python脚本django18 / bin / python
Because you are creating env with python 2.7 and then with python 3.3, the django18/bin/python script is still pointing at python 2.7. 因为你用python 2.7然后用python 3.3创建env,django18 / bin / python脚本仍然指向python 2.7。 Edit
django18/bin/python
or remove the env and only use the mkvirtualenv --python=/usr/bin/python3.3 django18
command. 编辑
django18/bin/python
或删除env并仅使用mkvirtualenv --python=/usr/bin/python3.3 django18
命令。
Old answer: 老答案:
From the link you provided: 从您提供的链接:
TIP: if you want to use Python 3 for your virtualenv, use mkvirtualenv --python=/usr/bin/python3.4 django18
提示:如果你想使用Python 3作为你的virtualenv,请使用mkvirtualenv --python = / usr / bin / python3.4 django18
https://www.pythonanywhere.com/wiki/VirtualEnvForNewerDjango https://www.pythonanywhere.com/wiki/VirtualEnvForNewerDjango
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.