【发布时间】:2015-10-01 17:12:19
【问题描述】:
为了使用 Python 3.3 和 Django 1.8,我正在使用 Virtualenv(用于 PythonAnywhere 中的网络应用)
我按照以下说明进行操作: https://help.pythonanywhere.com/pages/VirtualEnvForNewerDjango
进入控制台,显示我使用的是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.
>>>
这也是我指定要在我的网络应用程序中使用的版本:
Python version:3.3 (in the code pane)
但是,当我在 Virtualenv 窗格中指向 Virtualenv 目录(名为 django18)时,我收到以下警告:
This virtualenv seems to have the wrong Python version (2.7 instead of 3.3).
这是所有控制台(我在创建应用程序并指定 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
另见:
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 $
我还应该在哪里指向 Python 3.3?
【问题讨论】:
-
你确定是同一个目录吗?
-
好吧,你是怎么开始在终端中使用
django18的;activate脚本在哪里?它们通常放置在~/.virtualenvs,但不是必需。 -
需要检查的两件事 1. 创建 virtualenv 时是否指定了 python 版本?尝试删除 virtualenv 并再次创建它? 2. 当您在激活 virtualenv 的 bash 控制台中运行
which python时,您看到的路径是什么 -
感谢@conrad 查看新编辑
标签: python django pythonanywhere