简体   繁体   English

pycharm 中的 Pip 在 conda env 中安装包,而不是在项目内的活动 venv 中

[英]Pip in pycharm install packages in conda env and not in active venv inside project

i'm having a weird problem...我有一个奇怪的问题...

I can install packages using the built-in package manager in pycharm.我可以使用 pycharm 中的内置 package 管理器安装软件包。 But for some reason everytime i use "pip install (xx)" it is installing the packages in a conda env somewhere on my mac...但是由于某种原因,每次我使用“pip install (xx)”时,它都会将软件包安装在我 mac 上某处的 conda env 中......

How can i solve this?我该如何解决这个问题?

I've tried the following: close --> reopen pycharm // deactivate and activate the venv // Checked project intepreter is the right one (which it is...)我尝试了以下方法:关闭 --> 重新打开 pycharm // 停用并激活 venv // 检查项目解释器是正确的(它是...)

在此处输入图像描述

在此处输入图像描述

You're inside the virtual environment venv , while being inside the Conda base environment (note the (venv) and (base) to the left of your prompt).您在虚拟环境venv中,同时在 Conda base环境中(注意提示左侧的(venv)(base) )。 Conda is likely overriding your venv 's pip . Conda 可能会覆盖您的venvpip

My bet as to why this is happening is that, during installation, you set Conda to autostart its base environment whenever a new terminal is open (be it inside PyCharm or not).我打赌为什么会发生这种情况是,在安装过程中,您将 Conda 设置为在新终端打开时自动启动其base环境(无论是否在 PyCharm 内)。

You can try to either:您可以尝试:

    1. exit Conda (with conda deactivate ) and try pip install again (check to see that you're still inside the venv virtual environment).退出 Conda(使用conda deactivate )并再次尝试pip install (检查您是否仍在venv虚拟环境中)。
    1. install the packages directly from PyCharm's GUI - note the small + sign on the bottom-left of the package list.直接从 PyCharm 的 GUI 安装软件包 - 注意 package 列表左下角的小+符号。 This won't solve the issue related to your terminal, but will function as a workaround for now.这不会解决与您的终端相关的问题,但现在将 function 作为解决方法。

Note that these aren't guaranteed to work, because you may have additional configurations on your system (either installed directly by you, or indirectly by Conda when you installed it).请注意,这些不能保证有效,因为您的系统上可能有其他配置(由您直接安装,或在安装时由 Conda 间接安装)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM