Python 无法在 Anaconda 中 pip 安装包

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/25467595/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-18 20:15:39  来源:igfitidea点击:

Unable to pip install packages in Anaconda

pythonmacospipanaconda

提问by Nyxynyx

Just downloaded and installed anaconda 3.6.2 on Mac OSX Mavericks and I need to install a package seabornwhich is not pre-installed with anaconda.

刚刚在 Mac OSX Mavericks 上下载并安装了 anaconda 3.6.2,我需要安装一个seaborn未预装 anaconda的软件包。

$ conda install seaborn
Fetching package metadata: ..
Error: No packages found in current osx-64 channels matching: seaborn

You can search for this package on Binstar with

    binstar search -t conda seaborn

You may need to install the Binstar command line client with

    conda install binstar

Next I tried to use pipto install the package

接下来我尝试使用pip安装包

$ which pip
/Users/username/anaconda/bin/pip

$ pip install seaborn
Could not find an activated virtualenv (required).

Tried activating rootAnaconda env again, but still does not work

root再次尝试激活Anaconda env,但仍然不起作用

$ source activate root
discarding /Users/username/anaconda/bin from PATH
prepending /Users/username/anaconda/bin to PATH

$ pip install seaborn
Could not find an activated virtualenv (required).

Next I tried activating a virualenv and pip installworks.

接下来我尝试激活一个 virualenv 并pip install工作。

workon testEnv
pip install seaborn

Now I launched iPython notebookfrom Anaconda's launcher. But the seabornpackage does not seem to be found!

现在我iPython notebook从 Anaconda 的启动器启动。但是seaborn好像没有找到这个包!

Was the seabornpackage really installed?

seaborn包安装真的?

enter image description here

在此处输入图片说明

In ~/bashprofile, I have:

~/bashprofile,我有:

# virutalenvwrapper
export WORKON_HOME=$HOME/.virtualenvs
source /Users/username/.virtualenvs/datasci/bin/virtualenvwrapper.sh

# added by Anaconda 2.0.1 installer
export PATH="/Users/username/anaconda/bin:$PATH"


Update

更新

Removed the 2 virtualenvwrapper lines, reloaded .bash_profile, but pip installstill gives the error Could not find an activated virtualenv (required).Activating another conda environment source activate testenvdoes not help.

删除了 2 个 virtualenvwrapper 行,重新加载了 .bash_profile,但pip install仍然出现错误Could not find an activated virtualenv (required).激活另一个 conda 环境source activate testenv没有帮助。

$ source activate ~/.bash_profile
$ pip install seaborn
Could not find an activated virtualenv (required).

$ source activate testenv
discarding /Users/username/anaconda/bin from PATH
prepending /Users/username/anaconda/envs/testenv/bin to PATH
$ pip install seaborn
Could not find an activated virtualenv (required).

回答by asmeurer

Remove the virtualenvwrapper lines from your bashprofile. With Anaconda, you should use conda environments instead of virtualenvs, and using virtualenvs can end up breaking your conda environments.

从 bashprofile 中删除 virtualenvwrapper 行。使用 Anaconda,您应该使用 conda 环境而不是 virtualenvs,并且使用 virtualenvs 最终会破坏您的 conda 环境。

回答by Mark Unsworth

You need to install the anaconda version of pip. Just run:

您需要安装 anaconda 版本的 pip。赶紧跑:

conda install pip

This will install pip inside of the activated conda environment

这将在激活的 conda 环境中安装 pip

回答by mary82

I Had the same problem installing ggplot using Mac. If you execute from Terminal:

我在使用 Mac 安装 ggplot 时遇到了同样的问题。如果从终端执行:

/anaconda/bin/pip install module_name

it works. I hope it can help!

有用。我希望它能有所帮助!

MC

MC

回答by Dennis

Maybe just put this in your bash_profile:

也许只是把它放在你的 bash_profile 中:

export PIP_REQUIRE_VIRTUALENV=false

That was my issue, I forgot that I had set up PIP this way.

那是我的问题,我忘了我是这样设置 PIP 的。

回答by Piyush Majgawali

Try entering the command in Anaconda Promptand not Command Prompt.

尝试在Anaconda Prompt而不是 Command Prompt 中输入命令。