簡體   English   中英

無法在 Anaconda 中 pip 安裝包

[英]Unable to pip install packages in Anaconda

剛剛在 Mac OSX Mavericks 上下載並安裝了 anaconda 3.6.2,我需要安裝一個未預裝 anaconda 的包seaborn

$ 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

接下來我嘗試使用pip安裝包

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

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

再次嘗試激活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).

接下來我嘗試激活一個 virualenv 並且pip install工作。

workon testEnv
pip install seaborn

現在我從 Anaconda 的啟動器啟動了iPython notebook 但是seaborn包好像沒有找到!

seaborn包真的安裝了嗎?

在此處輸入圖片說明

~/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"

更新

刪除了 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).

我在使用 Mac 安裝 ggplot 時遇到了同樣的問題。 如果從終端執行:

/anaconda/bin/pip install module_name

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

MC

您需要安裝 anaconda 版本的 pip。 趕緊跑:

conda install pip

這將在激活的 conda 環境中安裝 pip

從 bashprofile 中刪除 virtualenvwrapper 行。 使用 Anaconda,您應該使用 conda 環境而不是 virtualenvs,並且使用 virtualenvs 最終會破壞您的 conda 環境。

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

export PIP_REQUIRE_VIRTUALENV=false

那是我的問題,我忘了我是這樣設置 PIP 的。

嘗試在Anaconda Prompt而不是 Command Prompt 中輸入命令。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM