7
回答
mac 安装多次python后不能使用pip
滴滴云服务器,限时包月0.9元,为开发者而生>>>   

running install
Checking .pth file support in /lib/python2.7/site-packages/
/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python -E -c pass

TEST FAILED: /lib/python2.7/site-packages/ 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:

    /lib/python2.7/site-packages/

and your PYTHONPATH environment variable currently contains:

    ''

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://setuptools.readthedocs.io/en/latest/easy_install.html#custom-installation-locations


Please make the appropriate changes for your system and try again.
 

举报
西二三旗
发帖于2周前 7回/102阅
共有7个答案 最后回答: 3天前

引用来自“iforgetmyname”的评论

检查你的pip安装地址是不是/lib/python2.7/site-packages/, 旧版本的macOS是在这里的,新版本的macOS把地址移动到了/Library/Python/2.7/site-packages,可能升级的时候没有调整pip的配置文件。

如果pip是安装到了/Library/Python/2.7/site-packages里面,把这个加到PYTHONPATH里面去。

如果是用作开发环境的话还是推荐用HomeBrew

引用来自“西二三旗”的评论

我把系统的python删除了,用brew 安装还是不行,你有好的修复方案吗?谢谢!

引用来自“iforgetmyname”的评论

你能把这些信息给我吗, 谢谢:

1、PATH 环境变量

2、PYTHONPATH 环境变量

3、python sys 包里面的sys.path

引用来自“西二三旗”的评论

PATH: 

/Users/shichaopeng/Program/tools/google-cloud/google-cloud-sdk/bin:/Users/shichaopeng/.gvm/pkgsets/go1.7.4/global/bin:/Users/shichaopeng/.gvm/gos/go1.7.4/bin:/Users/shichaopeng/.gvm/pkgsets/go1.7.4/global/overlay/bin:/Users/shichaopeng/.gvm/bin:/Users/shichaopeng/.gvm/bin:/Users/shichaopeng/.sdkman/candidates/groovy/current/bin:/Users/shichaopeng/.gvm/pkgsets/go1.4.2/global/bin:/Users/shichaopeng/.gvm/gos/go1.4.2/bin:/Users/shichaopeng/.gvm/pkgsets/go1.4.2/global/overlay/bin:/Users/shichaopeng/.gvm/bin:/Users/shichaopeng/.gvm/bin:/usr/local/bin:/Library/Java/JavaVirtualMachines/jdk1.8.0_25.jdk/Contents/Home/bin:/usr/local/bin:/Users/shichaopeng/Program/tools/apache-maven-3.2.5/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/go/bin:/Applications/Android Studio.app/sdk/platform-tools:/Applications/Android Studio.app/sdk/tools

没有 PYTHONPATH

python sys.path

 

>>> print sys.path
['', '/Library/Frameworks/Python.framework/Versions/2.7/lib/python27.zip', '/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7', '/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-darwin', '/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac', '/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac/lib-scriptpackages', '/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk', '/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-old', '/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload', '/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages']

因为/lib/python2.7/site-packages/ 这个目录不在你的modules查找目录里面,所以会报错, 可以把这个目录加到PYTHONPATH里面或者加到sys.path里面

PYTHONPATH=/lib/python2.7/site-packages/:$PATHON
export PYTHONPATH

把这个加到你的bashrc里面,或者

import sys
sys.path.insert(0, "/lib/python2.7/site-packages/")

然后重启环境再试一试

检查你的pip安装地址是不是/lib/python2.7/site-packages/, 旧版本的macOS是在这里的,新版本的macOS把地址移动到了/Library/Python/2.7/site-packages,可能升级的时候没有调整pip的配置文件。

如果pip是安装到了/Library/Python/2.7/site-packages里面,把这个加到PYTHONPATH里面去。

如果是用作开发环境的话还是推荐用HomeBrew

引用来自“iforgetmyname”的评论

检查你的pip安装地址是不是/lib/python2.7/site-packages/, 旧版本的macOS是在这里的,新版本的macOS把地址移动到了/Library/Python/2.7/site-packages,可能升级的时候没有调整pip的配置文件。

如果pip是安装到了/Library/Python/2.7/site-packages里面,把这个加到PYTHONPATH里面去。

如果是用作开发环境的话还是推荐用HomeBrew

我把系统的python删除了,用brew 安装还是不行,你有好的修复方案吗?谢谢!

引用来自“iforgetmyname”的评论

检查你的pip安装地址是不是/lib/python2.7/site-packages/, 旧版本的macOS是在这里的,新版本的macOS把地址移动到了/Library/Python/2.7/site-packages,可能升级的时候没有调整pip的配置文件。

如果pip是安装到了/Library/Python/2.7/site-packages里面,把这个加到PYTHONPATH里面去。

如果是用作开发环境的话还是推荐用HomeBrew

引用来自“西二三旗”的评论

我把系统的python删除了,用brew 安装还是不行,你有好的修复方案吗?谢谢!

你能把这些信息给我吗, 谢谢:

1、PATH 环境变量

2、PYTHONPATH 环境变量

3、python sys 包里面的sys.path

引用来自“iforgetmyname”的评论

检查你的pip安装地址是不是/lib/python2.7/site-packages/, 旧版本的macOS是在这里的,新版本的macOS把地址移动到了/Library/Python/2.7/site-packages,可能升级的时候没有调整pip的配置文件。

如果pip是安装到了/Library/Python/2.7/site-packages里面,把这个加到PYTHONPATH里面去。

如果是用作开发环境的话还是推荐用HomeBrew

引用来自“西二三旗”的评论

我把系统的python删除了,用brew 安装还是不行,你有好的修复方案吗?谢谢!

引用来自“iforgetmyname”的评论

你能把这些信息给我吗, 谢谢:

1、PATH 环境变量

2、PYTHONPATH 环境变量

3、python sys 包里面的sys.path

PATH: 

/Users/shichaopeng/Program/tools/google-cloud/google-cloud-sdk/bin:/Users/shichaopeng/.gvm/pkgsets/go1.7.4/global/bin:/Users/shichaopeng/.gvm/gos/go1.7.4/bin:/Users/shichaopeng/.gvm/pkgsets/go1.7.4/global/overlay/bin:/Users/shichaopeng/.gvm/bin:/Users/shichaopeng/.gvm/bin:/Users/shichaopeng/.sdkman/candidates/groovy/current/bin:/Users/shichaopeng/.gvm/pkgsets/go1.4.2/global/bin:/Users/shichaopeng/.gvm/gos/go1.4.2/bin:/Users/shichaopeng/.gvm/pkgsets/go1.4.2/global/overlay/bin:/Users/shichaopeng/.gvm/bin:/Users/shichaopeng/.gvm/bin:/usr/local/bin:/Library/Java/JavaVirtualMachines/jdk1.8.0_25.jdk/Contents/Home/bin:/usr/local/bin:/Users/shichaopeng/Program/tools/apache-maven-3.2.5/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/go/bin:/Applications/Android Studio.app/sdk/platform-tools:/Applications/Android Studio.app/sdk/tools

没有 PYTHONPATH

python sys.path

 

>>> print sys.path
['', '/Library/Frameworks/Python.framework/Versions/2.7/lib/python27.zip', '/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7', '/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-darwin', '/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac', '/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac/lib-scriptpackages', '/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk', '/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-old', '/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload', '/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages']

引用来自“iforgetmyname”的评论

检查你的pip安装地址是不是/lib/python2.7/site-packages/, 旧版本的macOS是在这里的,新版本的macOS把地址移动到了/Library/Python/2.7/site-packages,可能升级的时候没有调整pip的配置文件。

如果pip是安装到了/Library/Python/2.7/site-packages里面,把这个加到PYTHONPATH里面去。

如果是用作开发环境的话还是推荐用HomeBrew

引用来自“西二三旗”的评论

我把系统的python删除了,用brew 安装还是不行,你有好的修复方案吗?谢谢!

引用来自“iforgetmyname”的评论

你能把这些信息给我吗, 谢谢:

1、PATH 环境变量

2、PYTHONPATH 环境变量

3、python sys 包里面的sys.path

引用来自“西二三旗”的评论

PATH: 

/Users/shichaopeng/Program/tools/google-cloud/google-cloud-sdk/bin:/Users/shichaopeng/.gvm/pkgsets/go1.7.4/global/bin:/Users/shichaopeng/.gvm/gos/go1.7.4/bin:/Users/shichaopeng/.gvm/pkgsets/go1.7.4/global/overlay/bin:/Users/shichaopeng/.gvm/bin:/Users/shichaopeng/.gvm/bin:/Users/shichaopeng/.sdkman/candidates/groovy/current/bin:/Users/shichaopeng/.gvm/pkgsets/go1.4.2/global/bin:/Users/shichaopeng/.gvm/gos/go1.4.2/bin:/Users/shichaopeng/.gvm/pkgsets/go1.4.2/global/overlay/bin:/Users/shichaopeng/.gvm/bin:/Users/shichaopeng/.gvm/bin:/usr/local/bin:/Library/Java/JavaVirtualMachines/jdk1.8.0_25.jdk/Contents/Home/bin:/usr/local/bin:/Users/shichaopeng/Program/tools/apache-maven-3.2.5/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/go/bin:/Applications/Android Studio.app/sdk/platform-tools:/Applications/Android Studio.app/sdk/tools

没有 PYTHONPATH

python sys.path

 

>>> print sys.path
['', '/Library/Frameworks/Python.framework/Versions/2.7/lib/python27.zip', '/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7', '/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-darwin', '/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac', '/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac/lib-scriptpackages', '/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk', '/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-old', '/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload', '/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages']

引用来自“iforgetmyname”的评论

因为/lib/python2.7/site-packages/ 这个目录不在你的modules查找目录里面,所以会报错, 可以把这个目录加到PYTHONPATH里面或者加到sys.path里面

PYTHONPATH=/lib/python2.7/site-packages/:$PATHON
export PYTHONPATH

把这个加到你的bashrc里面,或者

import sys
sys.path.insert(0, "/lib/python2.7/site-packages/")

然后重启环境再试一试

好的,已经解决,多谢!

顶部