2016-02-13 228 views
0

我剛剛在Mac OSX Yosemite上安裝了Anaconda,並且我已經啓動並運行了包括Python,但我認爲當我嘗試「pip install」新模塊時,我的路徑有問題。Anaconda:安裝Python模塊

「哪個python」和「哪個pip」命令都指向我的Anaconda文件夾。此外,做一個「pip安裝webbpsf」似乎會通過,但模塊不會出現在「conda列表」中,也不會在我運行腳本時導入(ImportError:沒有名爲webbpsf的模塊)。

我試圖手動(從下載的模塊目錄)使用「python setup.py install」來安裝webbpsf模塊,但我收到一個錯誤,我認爲它指向了問題的根源,即/ username/py-lib/path。請看下圖:

Checking .pth file support in /username/py-lib/ 
/username/anaconda/bin/python -E -c pass 
TEST FAILED: /username/py-lib/ does NOT support .pth files 
error: bad install directory or PYTHONPATH 

You are attempting to install a package to a directory that is not 
on PYTHONPATH and which Python does not read ".pth" files from. The 
installation directory you specified (via --install-dir, --prefix, or 
the distutils default setting) was: 

/username/py-lib/ 

and your PYTHONPATH environment variable currently contains: 

'/username/anaconda/lib/python2.7/site-packages' 

Here are some of your options for correcting the problem: 

* You can choose a different installation directory, i.e., one that is 
    on PYTHONPATH or supports .pth files 

* You can add the installation directory to the PYTHONPATH environment 
    variable. (It must then also be on PYTHONPATH whenever you run 
    Python and want to use the package(s) you are installing.) 

* You can set up the installation directory to support ".pth" files by 
    using one of the approaches described here: 

    https://pythonhosted.org/setuptools/easy_install.html#custom-installation-locations 

我挖深,試圖找到其中/如何/ PY-LIB /路徑設置,我看着推薦鏈接無濟於事。我在這裏錯過了什麼?

+0

Anaconda附帶它自己的Python。請參閱http://stackoverflow.com/questions/17386880/does-anaconda-create-a-separate-pythonpath-variable-for-each-new-environment – Sarien

回答

0

嘗試使用anaconda文件夾中的python bin文件來安裝setup.py文件。

+0

只是嘗試和相同的錯誤消息。 python setup.py install必須有一些配置來設置有問題的目錄,但我似乎無法找到它。 – user2920100

0

我的問題是在〜/ .pydistutils.cfg中強制設置了目錄/ username/py-lib /(也是/ username/py-bin /)。我刪除該文件,「pip install whatever_module」完成它應該做的事情。