虚拟环境已激活

2024-04-20 11:32:52 发布

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

运行以下命令

poetry shell

返回以下错误

/home/harshagoli/.poetry/lib/poetry/_vendor/py2.7/subprocess32.py:149: RuntimeWarning: The _posixsubprocess module is not being used. Child process reliability may suffer if your program uses threads.                                                                                                                                                                                    
  "program uses threads.", RuntimeWarning)                                                                                                                                                    
The currently activated Python version 2.7.17 is not supported by the project (^3.7).                                                                                                         
Trying to find and use a compatible version.                                                                                                                                                  
Using python3 (3.7.5)                                                                                                                                                                         
Virtual environment already activated: /home/harshagoli/.cache/pypoetry/virtualenvs/my-project-0wt3KWFj-py3.7

我怎样才能克服这个错误?为什么这个命令不起作用


Tags: the命令projecthomepoetryisversion错误
3条回答

poetry shell是一个真正有缺陷的命令,维护人员经常讨论这个问题。此特定问题的解决方法是手动激活shell。下面的代码可能值得使用别名

source "$( poetry env list  full-path )/bin/activate"

这类似于激活正常的虚拟环境。但我们需要找到诗歌虚拟环境的路径

我们可以通过poetry env info path找到路径

source $(poetry env info  path)/bin/activate

this poetry demo中解释

我必须做以下几件事

source "$( poetry env list  full-path | grep Activated | cut -d' ' -f1 )/bin/activate"

相关问题 更多 >