为什么Python解释器不使用虚拟环境(venv)?

huangapple go评论53阅读模式
英文:

Why python interpreter not using venv

问题

I set up virtual env in my pycharm and i have interpreter of python in that venv and my console shows me that im using that but for some reason i still have packages of my main interpreter

我在PyCharm中设置了虚拟环境,并且在该虚拟环境中有Python解释器,我的控制台显示我正在使用它,但出于某种原因,我仍然拥有我的主要解释器的包。

How can i solve that?

我该如何解决这个问题?

This is my venv interpreter and im using it
这是我的虚拟环境解释器,我正在使用它

But for some reason in terminal i still has previous intrepreter from another project
但出于某种原因,在终端中,我仍然拥有来自另一个项目的先前解释器。

英文:

I set up virtual env in my pycharm and i have interpreter of python in that venv and my console shows me that im using that but for some reason i still have packages of my main interpreter

How can i solve that?

This is my venv interpreter and im using it
为什么Python解释器不使用虚拟环境(venv)?

But for some reason in terminal i still has previous intrepreter from another project 为什么Python解释器不使用虚拟环境(venv)?

为什么Python解释器不使用虚拟环境(venv)?

为什么Python解释器不使用虚拟环境(venv)?

答案1

得分: 2

在该终端中,您可以运行 which python3 (在 Python REPL 外)。您应该看到它不是您的桌面文件夹的 venv python...

您需要使用 cmd.exe 作为终端。然后在运行 py3/python3pip 命令之前,需要调用该文件夹中 venv 的 activate.bat 文件。

否则,使用 Pycharm 内置的 pip 管理对话框,它应该自动链接到项目解释器,而不是修改 PyCharm 终端设置以适用于所有项目。

英文:

In that terminal, you can run which python3 (outside of the Python REPL). You should see it's not your Desktop folder's venv python...

You need to use cmd.exe for the terminal. Then you need to invoke the activate.bat file of the venv in that folder before running py3/python3 or pip commands.

Otherwise, use Pycharm's built-in pip management dialog which should automatically link to the project interpreter, rather than modify PyCharm terminal settings for all projects.

huangapple
  • 本文由 发表于 2023年4月20日 01:29:51
  • 转载请务必保留本文链接:https://go.coder-hub.com/76057312.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定