Unable to pip install packages in Anaconda

2020-02-21 07:58发布

Just downloaded and installed anaconda 3.6.2 on Mac OSX Mavericks and I need to install a package seaborn which is not pre-installed with 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 pip to install the package

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

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

Tried activating root Anaconda env again, but still does not work

$ 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 install works.

workon testEnv
pip install seaborn

Now I launched iPython notebook from Anaconda's launcher. But the seaborn package does not seem to be found!

Was the seaborn package really installed?

enter image description here

In ~/bashprofile, I have:

# 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 install still gives the error Could not find an activated virtualenv (required). Activating another conda environment source activate testenv does not help.

$ 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).

5条回答
Viruses.
2楼-- · 2020-02-21 08:40

Maybe just put this in your bash_profile:

export PIP_REQUIRE_VIRTUALENV=false

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

查看更多
男人必须洒脱
3楼-- · 2020-02-21 08:41

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.

查看更多
We Are One
4楼-- · 2020-02-21 08:57

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

conda install pip

This will install pip inside of the activated conda environment

查看更多
做自己的国王
5楼-- · 2020-02-21 08:58

Try entering the command in Anaconda Prompt and not Command Prompt.

查看更多
再贱就再见
6楼-- · 2020-02-21 09:01

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

//anaconda/bin/pip install module_name

it works. I hope it can help!

MC

查看更多
登录 后发表回答