Ich habe versucht, pip auf macOS sierra via brew zu installieren, aber jedes Mal, wenn die Binärdateien in /usr/local/Cellar/python/2.7.13/bin
nicht installiert werden.
Ich habe es versucht:
MacBook-Pro ➜ brew reinstall python
dann:
MacBook-Pro ➜ ~ which pip
pip not found
Ich habe den Pfad zu Python gefunden, der /usr/local/Cellar/python/2.7.13/bin
ist, aber keine Binärdatei für pip.
Ich habe auch den easy_install
-Ansatz ausprobiert:
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'
UPDATE:
Wenn ich brew postinstall python
starte, erhalte ich die folgende Fehlermeldung:
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
Sie müssen lediglich pip
installieren, das in macOS Sierra nicht automatisch installiert wird.
Sudo easy_install pip
ausführen
Unter Mac OS Sierra kann pip nicht über easy_install
installiert werden, da ein Problem mit der TLS-Version vorliegt. Die installierte Open-SSL-Version unterstützt TLS 1.2 nicht
Also installiere pip mit curl wie folgt:
curl https://bootstrap.pypa.io/get-pip.py | Sudo python
OK, viele dieser Antworten waren hilfreich, aber keiner von ihnen brachte mich ins Ziel. Ich verwende High Sierra 10.13.4. Das oben beschriebene Problem ist, dass Brew Pip im /usr/local/bin
-Verzeichnis installiert, Python jedoch in /usr/bin
(obwohl Carl, wie gesagt, Python3 korrekt zu /usr/local/bin
geht).
Mein unmittelbarer Anwendungsfall bezieht sich auf die Installation des Pakets Postgres BigSQL .
Ich habe folgende Schritte unternommen:
$ rm -rf ~/Library/Caches/Homebrew
$ Sudo rm -rf /usr/local/lib/python2.7/site-packages
$ brew reinstall python
erneut. Dadurch wird python-3.5.6.high_sierra
heruntergefahren und in /usr/local/bin/python3
eingefügt.which python
zeigt immer noch /usr/bin/python
brew install [email protected]
ausführen, wodurch [email protected]_3.high_sierra
heruntergezogen wird.which python
den korrekten Pfad /usr/local/bin/python
, in dem auch alle Ihre Pip-Dateien installiert sind. Jetzt funktioniert Pip.Sudo pip install --upgrade pip
tun. Bei Ihrer Sudinstallation muss etwas nicht stimmen.
Neueste macOS-Version.
~/ 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
Und es existiert definitiv.
~/ 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
Ich hatte dieses Problem und fand, dass dies die Lösung ist. BTW Pip wird nicht über Brew installiert. Es kommt mit python und python virtualenvs.
wenn Sie which python
ohne brew install python
eingeben, erhalten Sie die Position in /usr/bin/python
. Das ist das System python, mit dem wir nicht entwickeln wollen.
Also habe ich die folgenden Schritte unternommen. 1) brew install python
2) export PATH="/usr/local/opt/python/libexec/bin:$PATH"
Fügen Sie dies in Ihr ~/.bash_profile
3) source ~/.bash_profile
In Ihr Terminal ein. 4) Geben Sie which python
Ein, und das sollte geschehen hat den Treffpunkt zu /usr/local/opt/python/libexec/bin/python
geändert.
Auf diese Weise können Sie die Pip-Installation normal ausführen und die Brew-Version von Python verwenden.
Nun, bevor sich High Sierra python in /usr/local/bin
Befand, zeigt es aus irgendeinem Grund automatisch auf /usr/local/bin
, Wenn Sie /usr/bin
, das ist also die einzige Lösung, die ich finden konnte.
Python3 hat dieses Problem nicht. Wenn Sie brew install python3
Und which python3
Eingeben, werden Sie feststellen, dass es sich in /usr/local/bin/python3
Befindet.
Nach allem, was es wert ist, fand ich nach dem Upgrade auf High Sierra meine Maschine ziemlich unbrauchbar für die Entwicklung und stürzte sogar oft ab.
In Bezug auf Python hatte ich ein Rechteproblem im Ordner "site-packages". Daher hat die Neuinstallation nicht funktioniert:
$ 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
...
Um es zu beheben, entfernte ich die Site-Pakete vollständig:
$ Sudo rm -rf /usr/local/lib/python2.7/site-packages
Mit dieser Neuinstallation von python2 und einem funktionierenden Pip2 funktionierte es wie ein Zauber:
$ 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
Hoffentlich hilft das.
Die Fehlermeldung hat die Antwort für Sie ...
Entfernen Sie /Users/justin/.venvburrito/lib/python/distribute-0.6.35-py2.7.Egg/
und führen Sie brew reinstall python
aus. setuptools
ist die falsche Version.