2016-02-13 230 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”完成它应该做的事情。