2015-02-11 4 views
5

Ich habe Python 2.7.9 mit Homebrew auf meinem Mac installiert, und Homebrew installiert auch Pip. Es gibt auch eine ältere, nicht verwendete Version von Python, die standardmäßig auf meinem Mac installiert wurde.Probleme mit der Aktualisierung Pip in Homebrew Python 2.7 Installation

Das Problem ist, dass, wenn ich versuche, Pip (mit pip install --upgrade pip) zu aktualisieren, scheint Pip die Version von Pip, die mit der älteren, Standardversion von Python kommt, zu aktualisieren. Hier ist, was passiert (nach einer Neuinstallation von Python tun 2.7.9, das heißt, brew remove python gefolgt von brew install python):

$ pip -V 
pip 6.0.7 from /usr/local/Cellar/python/2.7.9/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pip-6.0.7-py2.7.egg (python 2.7) 

Die oben richtig scheint. Es passiert jedoch Folgendes:

$ pip install --upgrade pip 
You are using pip version 6.0.7, however version 6.0.8 is available. 
You should consider upgrading via the 'pip install --upgrade pip' command. 
Collecting pip from https://pypi.python.org/packages/py2.py3/p/pip/pip-6.0.8-py2.py3-none-any.whl#md5=41e73fae2c86ba2270ff51c1d86f7e09 
    Using cached pip-6.0.8-py2.py3-none-any.whl 
Installing collected packages: pip 
    Found existing installation: pip 6.0.7 
    Uninstalling pip-6.0.7: 
     Successfully uninstalled pip-6.0.7 

Successfully installed pip-1.4.1 

Warum wurde pip 1.4.1 installiert? Jetzt bekomme ich:

$ pip -V 
pip 1.4.1 from /Library/Python/2.7/site-packages/pip-1.4.1-py2.7.egg (python 2.7) 

Das scheint mit der älteren Standardversion von Python zu entsprechen. Wenn ich versuche, wieder zu aktualisieren, scheitert es:

$ pip install --upgrade pip 
Downloading/unpacking pip from https://pypi.python.org/packages/source/p/pip/pip-6.0.8.tar.gz#md5=2332e6f97e75ded3bddde0ced01dbda3 
    Downloading pip-6.0.8.tar.gz (1.2MB): 1.2MB downloaded 
    Running setup.py egg_info for package pip 

    warning: no previously-included files found matching '.coveragerc' 
    warning: no previously-included files found matching '.mailmap' 
    warning: no previously-included files found matching '.travis.yml' 
    warning: no previously-included files found matching 'pip/_vendor/Makefile' 
    warning: no previously-included files found matching 'tox.ini' 
    warning: no previously-included files found matching 'dev-requirements.txt' 
    no previously-included directories found matching '.travis' 
    no previously-included directories found matching 'docs/_build' 
    no previously-included directories found matching 'contrib' 
    no previously-included directories found matching 'tasks' 
    no previously-included directories found matching 'tests' 
Installing collected packages: pip 
    Found existing installation: pip 1.4.1 
    Uninstalling pip: 
Cleaning up... 
Exception: 
Traceback (most recent call last): 
    File "/Library/Python/2.7/site-packages/pip-1.4.1-py2.7.egg/pip/basecommand.py", line 134, in main 
    status = self.run(options, args) 
    File "/Library/Python/2.7/site-packages/pip-1.4.1-py2.7.egg/pip/commands/install.py", line 241, in run 
    requirement_set.install(install_options, global_options, root=options.root_path) 
    File "/Library/Python/2.7/site-packages/pip-1.4.1-py2.7.egg/pip/req.py", line 1294, in install 
    requirement.uninstall(auto_confirm=True) 
    File "/Library/Python/2.7/site-packages/pip-1.4.1-py2.7.egg/pip/req.py", line 525, in uninstall 
    paths_to_remove.remove(auto_confirm) 
    File "/Library/Python/2.7/site-packages/pip-1.4.1-py2.7.egg/pip/req.py", line 1639, in remove 
    renames(path, new_path) 
    File "/Library/Python/2.7/site-packages/pip-1.4.1-py2.7.egg/pip/util.py", line 294, in renames 
    shutil.move(old, new) 
    File "/usr/local/Cellar/python/2.7.9/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py", line 300, in move 
    rmtree(src) 
    File "/usr/local/Cellar/python/2.7.9/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py", line 247, in rmtree 
    rmtree(fullname, ignore_errors, onerror) 
    File "/usr/local/Cellar/python/2.7.9/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py", line 252, in rmtree 
    onerror(os.remove, fullname, sys.exc_info()) 
    File "/usr/local/Cellar/python/2.7.9/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py", line 250, in rmtree 
    os.remove(fullname) 
OSError: [Errno 13] Permission denied: '/Library/Python/2.7/site-packages/pip-1.4.1-py2.7.egg/EGG-INFO/dependency_links.txt' 

Storing complete log in /Users/[me]/.pip/pip.log 

installiert jedoch pip richtig /usr/local/lib/python2.7/site-packages (die Homebrew-Version zur Verfügung gestellt), und ich habe keine offensichtlichen Probleme mit pip mit Modulen zu installieren und die Module verwenden. Hier ist die Ausgabe von which, nachdem alle oben:

$ which pip 
/usr/local/bin/pip 
$ which python 
/usr/local/bin/python 

Was ist los? Jede Hilfe wäre willkommen.

+0

Das sieht tatsächlich komisch aus. Ich würde versuchen: '/ usr/local/bin/python -E -m pip installieren --upgrade pip' – cel

+0

' 1.4.1 von /Library/Python/2.7/site-packages/pip-1.4.1-py2 pip. 7.egg ist OSX-System-weite Python-Installation, jetzt Homebrew, und Sie sollten nicht damit zu tun haben. M Stellen Sie sicher, 'pip' binary läuft von'/usr/local/bin'. –

+0

@MikkoOhtamaa Ich bin mir ziemlich sicher, dass '/ usr/local/bin/pip' ausgeführt wird, wenn ich' pip' betreibe, nach der Ausgabe von 'which pip' zu urteilen. Ist das eine vernünftige Sache für mich zu schließen? – dowbuen

Antwort

7

Ich denke, das ist das gleiche Problem ist hier beschrieben: https://github.com/pypa/pip/issues/2319

Es wird von pip misbehaving verursacht wird, wenn ein anderes pip-Ei in sys.path gibt.

Die einfachste Lösung ist, weiter sudo python -m pip uninstall pip zu laufen, bis das funktioniert, und dann brew postinstall python (die Pip installiert).

+0

Das hat bei mir funktioniert, danke! Die Verbindung war auch hilfreich, um zu verstehen, was passiert ist. – dowbuen

+0

Ich weiß, es ist ein zwei Jahre alter Kommentar - aber das hat mir königlich geholfen! Vielen Dank – gonzofish

0

Ich hatte dieses Problem auch (Homebrew Python 2.7.9 auf Yosemite). Ich lief es, zu versuchen, pip install virtualenv zu tun:

> which pip2.7 
/usr/local/bin/pip2.7 
> which python 
/usr/local/bin/python 
> pip install virtualenv 
Requirement already satisfied (use --upgrade to upgrade): virtualenv in /Library/Python/2.7/site-packages 
> pip install --upgrade virtualenv 
.. 
OSError: [Errno 13] Permission denied: '/Library/Python/2.7/site-packages/virtualenv-1.11.5-py2.7.egg-info/dependency_links.txt' 

ich es vorübergehend durch Ausblenden der Dateien in /Library/Python/2.7/site-packages gelöst. Und sie zurückbringen, als ich fertig war.

> pip install virtualenv 
Collecting virtualenv 
    Using cached virtualenv-12.0.7-py2.py3-none-any.whl 
Installing collected packages: virtualenv 

Successfully installed virtualenv-12.0.7 
> which virtualenv 
/usr/local/bin/virtualenv 
> 

Es funktioniert auch richtig. Ich bekomme 2.7.9 innerhalb der virtualenv und kann numpy, matplotlib, scipy installieren, und sie funktionieren.