2016-12-20 16 views
8

私はbrewを使ってmacOS sierraにpipをインストールしようとしていましたが、バイナリをインストールしないと完了するたびに/usr/local/Cellar/python/2.7.13/binにピップをインストールしようとしていました。MacOSにpipをインストールする

私が試してみた:

MacBook-Pro ➜ brew reinstall python 

を、その後:

MacBook-Pro ➜ ~ which pip 
pip not found 

私は/usr/local/Cellar/python/2.7.13/binあるのpythonのパスが、そこPIPの無バイナリを見つけました。

私もeasy_installアプローチを試みた:UPDATE

MacBook-Pro ➜ sudo easy_install pip 
Traceback (most recent call last): 
    File "/usr/bin/easy_install-2.7", line 11, in <module> 
    load_entry_point('setuptools==18.5', 'console_scripts', 'easy_install')() 
    File "/Library/Python/2.7/site-packages/pkg_resources.py", line 352, in load_entry_point 
    return get_distribution(dist).load_entry_point(group, name) 
    File "/Library/Python/2.7/site-packages/pkg_resources.py", line 2307, in load_entry_point 
    return ep.load() 
    File "/Library/Python/2.7/site-packages/pkg_resources.py", line 2021, in load 
    entry = __import__(self.module_name, globals(),globals(), ['__name__']) 
    File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/setuptools/__init__.py", line 12, in <module> 
    from setuptools.extension import Extension 
    File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/setuptools/extension.py", line 8, in <module> 
    from .dist import _get_unpatched 
    File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/setuptools/dist.py", line 21, in <module> 
    packaging = pkg_resources.packaging 
AttributeError: 'module' object has no attribute 'packaging' 

を:私はbrew postinstall pythonを実行すると

私は、次のエラーを取得しています:

MacBook-Pro ➜ ~ brew postinstall python 
==> Using the sandbox 
==> /usr/local/Cellar/python/2.7.13/bin/python -s setup.py --no-user-cfg install --force --verbose --single-version-externally-managed --rec 
==> /usr/local/Cellar/python/2.7.13/bin/python -s setup.py --no-user-cfg install --force --verbose --single-version-externally-managed --rec 
Last 15 lines from /Users/justin/Library/Logs/Homebrew/python/post_install.02.python: 

Traceback (most recent call last): 
    File "setup.py", line 92, in <module> 
    cmdclass={'test': PyTest}, 
    File "/usr/local/Cellar/python/2.7.13/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/core.py", line 111, in setup 
    _setup_distribution = dist = klass(attrs) 
    File "/Users/justin/.venvburrito/lib/python/distribute-0.6.35-py2.7.egg/setuptools/dist.py", line 225, in __init__ 
    _Distribution.__init__(self,attrs) 
    File "/usr/local/Cellar/python/2.7.13/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/dist.py", line 287, in __init__ 
    self.finalize_options() 
    File "/Users/justin/.venvburrito/lib/python/distribute-0.6.35-py2.7.egg/setuptools/dist.py", line 258, in finalize_options 
    ep.load()(self, ep.name, value) 
    File "/Users/justin/.venvburrito/lib/python/distribute-0.6.35-py2.7.egg/pkg_resources.py", line 2020, in load 
    raise ImportError("%r has no %r attribute" % (entry,attr)) 
ImportError: <module 'setuptools.dist' from '/Users/justin/.venvburrito/lib/python/distribute-0.6.35-py2.7.egg/setuptools/dist.pyc'> has no 'check_specifier' attribute 
+0

'sudo easy_install'は、pipをbrewディレクトリに入れません。 –

+0

' pip2'は存在しますか? –

+0

@ cricket_007 '/ usr/local/Cellar/python/2.7.13/bin'に' pip'または 'pip2'はありません。 – Justin

答えて

2

何かがあなたと間違っている必要があります醸造設備。

最新のmacOSバージョン。

~/ brew reinstall python 
==> Reinstalling python 
==> Downloading https://homebrew.bintray.com/bottles/python-2.7.13.sierra.bottle.tar.gz 
Already downloaded: ~/Library/Caches/Homebrew/python-2.7.13.sierra.bottle.tar.gz 
==> Pouring python-2.7.13.sierra.bottle.tar.gz 
==> Using the sandbox 
==> /usr/local/Cellar/python/2.7.13/bin/python -s setup.py --no-user-cfg install --force --verbose --single-version-externally-managed --record=installed.txt --install-scripts=/usr/local/Cellar/python/2.7 
==> /usr/local/Cellar/python/2.7.13/bin/python -s setup.py --no-user-cfg install --force --verbose --single-version-externally-managed --record=installed.txt --install-scripts=/usr/local/Cellar/python/2.7 
==> /usr/local/Cellar/python/2.7.13/bin/python -s setup.py --no-user-cfg install --force --verbose --single-version-externally-managed --record=installed.txt --install-scripts=/usr/local/Cellar/python/2.7 
==> Caveats 
Pip and setuptools have been installed. To update them 
    pip install --upgrade pip setuptools 

You can install Python packages with 
    pip install <package> 

They will install into the site-package directory 
    /usr/local/lib/python2.7/site-packages 

See: https://github.com/Homebrew/brew/blob/master/docs/Homebrew-and-Python.md 

.app bundles were installed. 
Run `brew linkapps python` to symlink these to /Applications. 
==> Summary 
    /usr/local/Cellar/python/2.7.13: 3,526 files, 48M 

これは間違いなく存在します。

~/ ls -l $(which pip) 
lrwxr-xr-x 1 cricket admin 31 Dec 19 19:43 /usr/local/bin/pip -> ../Cellar/python/2.7.13/bin/pip 
+0

私が 'brew postinstall python'を実行するとエラーが発生します。更新のためのオリジナルの質問を参照してください。 – Justin

+0

なぜそれを実行する必要があるのか​​分かりませんが、うまく動作します。 '〜/ Library/Caches/Homebrew'でキャッシュされたファイルを削除してみてください –

0

エラーメッセージがあなたのための答えを持っている...

/Users/justin/.venvburrito/lib/python/distribute-0.6.35-py2.7.egg/を削除し、brew reinstall pythonを実行します。 setuptoolsは間違ったバージョンです。

14

pipをインストールするだけで、macOS Sierraには自動的にインストールされません。

実行sudo easy_install pip

+0

魅力的な方法で作業しました:-) –

2

私はこの問題を持っていたし、私はこれが解決策であることが判明。 BTWピルはビールを介してインストールされていません。それは、PythonとPythonのvirtualenvsに付属しています。

which pythonと入力した場合、brew install pythonを入力しないと、/usr/bin/pythonに位置します。それは私たちが開発したくないシステムPythonです。

私は以下の手順を実行しました。 1)brew install python 2)export PATH="/usr/local/opt/python/libexec/bin:$PATH"配置することで自分の端末 4)which pythonを入力し、それが/usr/local/opt/python/libexec/bin/pythonに場所を変更しているはずで~/.bash_profile 3)source ~/.bash_profile

これにより、普通にpipインストールし、pythonのBREWバージョンを使用することができます。ハイシエラのpythonの前に今すぐ

はあなたのパスに/usr/local/binを配置する場合、それは自動的に/usr/binに戻って指すので、これは私が思い付くことができた唯一のソリューションです何らかの理由で/usr/local/binに配置するために使用されるが、。

brew install python3と入力した場合、which python3と入力すると、/usr/local/bin/python3にあることがわかります。

0

高いシエラにアップグレードした後、私のマシンは開発にはほとんど使えず、何度もクラッシュすることがありました。

のpythonについては、私はので、再インストールがうまくいかなかった、のsite-packagesフォルダ内の権利の問題があった:

$ brew reinstall python 

==> Reinstalling python 
==> Downloading https://homebrew.bintray.com/bottles/python-2.7.14.high_sierra.bottle.tar.gz 
Already downloaded: /Users/m/Library/Caches/Homebrew/python-2.7.14.high_sierra.bottle.tar.gz 
==> Pouring python-2.7.14.high_sierra.bottle.tar.gz 
==> /usr/local/Cellar/python/2.7.14/bin/python2 -s setup.py --no-user-cfg install --force --verbose --single-version-externally-managed --record=installed.txt --install-scripts=/usr/local/Cellar/python/2.7.14/bin --install- 
Last 15 lines from /Users/m/Library/Logs/Homebrew/python/post_install.01.python2: 
. 
. 
. 
copying build/lib/setuptools/script (dev).tmpl -> /usr/local/lib/python2.7/site-packages/setuptools 
copying build/lib/pkg_resources/_vendor/packaging/version.py -> /usr/local/lib/python2.7/site-packages/pkg_resources/_vendor/packaging 
error: could not delete '/usr/local/lib/python2.7/site-packages/pkg_resources/_vendor/packaging/version.py': Permission denied 
Warning: The post-install step did not complete successfully 
... 

をので、それを修正するために、私は完全にサイトのパッケージを削除したがこれにより

$ sudo rm -rf /usr/local/lib/python2.7/site-packages 

、python2を再インストールし、再度作業PIP2を有する、魅力のように働いた:

$ brew reinstall python 

$ which pip2 
/usr/local/bin/pip2 
$ which python2 
/usr/local/bin/python2 

$ which pip 
pip not found 
$ which python 
/usr/bin/python 

希望に役立ちます。

関連する問題