gpt4 book ai didi

python - 在 PythonAnywhere 中使用 Virtualenv 时错误的 Python 版本

转载 作者:太空宇宙 更新时间:2023-11-03 13:40:55 24 4
gpt4 key购买 nike

为了使用 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 Pane 中指向 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?

最佳答案

在我看来,您的 virtualenv 以某种方式同时包含 Python 2.7 和 3.3 版。尝试删除它并重新创建它:

rmvirtualenv django18
mkvirtualenv --python=/usr/bin/python3.3 django18
pip install django # reinstall django and any other packages you need.

为什么不顺便用Python 3.4呢?

关于python - 在 PythonAnywhere 中使用 Virtualenv 时错误的 Python 版本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31383359/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com