为什么虚拟环境运行系统python2.7而不是virtualpython3.6

2024-09-30 01:19:37 发布

您现在位置:Python中文网/ 问答频道 /正文

我在虚拟环境中创建了一个Django项目,venv像往常一样被PyCharm自动激活。一切都很好,但是当我把我的项目放入另一个文件夹时,项目解释器的设置由于旧的解释器路径而损坏。 所以现在,当我为解释器提供一个新的路径(当然,还有激活的venv)时,python从2.7版本的基本系统位置运行,而不是从venv运行。在

检查此项:

archeski@archeski-Inspiron-5558:~/Source/ecom/ecom$ source venv/bin/activate
(venv) archeski@archeski-Inspiron-5558:~/Source/ecom/ecom$ python --version
Python 2.7.15rc1
(venv) archeski@archeski-Inspiron-5558:~/Source/ecom/ecom$ python -c "import sys; print sys.executable"
/usr/bin/python

enter image description here

enter image description here

大约半年前在Windows10上也发生了同样的事情,解决方案只是从头开始在PyCharm中创建一个项目,然后移动所有源代码、db等。 现在,我正在运行Ubuntu 18.04


Tags: 项目django路径版本文件夹sourcebinvenv
1条回答
网友
1楼 · 发布于 2024-09-30 01:19:37

From https://intellij-support.jetbrains.com/hc/en-us/community/posts/115000062344-How-to-move-complete-Python-environment-to-new-PC-with-virtual-environment

Normally environments are tied to a specific path. That means that you cannot move an environment around or copy it to another computer. You can fix up an environment to make it relocatable with the command:

$ virtualenv relocatable ENV

The relocatable option currently has a number of issues, and is not guaranteed to work in all circumstances. It is possible that the option will be deprecated in a future version of virtualenv

相关问题 更多 >

    热门问题