ImportError: nessun modulo denominato pip


124

Sistema operativo: Mac OS X 10.7.5 Python Ver: 2.7.5

Ho installato setuptools 1.0 con ez_setup.py da https://pypi.python.org/pypi/setuptools Quindi scarico pip.1.4.1 pkg da https://pypi.python.org/pypi/pip/1.4.1 .

Esegui (sudo) python setup.py installin iTerm lo mostra

running install
running bdist_egg running egg_info writing requirements to
pip.egg-info/requires.txt writing pip.egg-info/PKG-INFO writing
top-level names to pip.egg-info/top_level.txt writing dependency_links
to pip.egg-info/dependency_links.txt writing entry points to
pip.egg-info/entry_points.txt warning: manifest_maker: standard file
'setup.py' not found

reading manifest file 'pip.egg-info/SOURCES.txt' writing manifest file
'pip.egg-info/SOURCES.txt' installing library code to
build/bdist.macosx-10.6-intel/egg running install_lib warning:
install_lib: 'build/lib' does not exist -- no Python modules to
install

creating build/bdist.macosx-10.6-intel/egg creating
build/bdist.macosx-10.6-intel/egg/EGG-INFO copying
pip.egg-info/PKG-INFO -> build/bdist.macosx-10.6-intel/egg/EGG-INFO
copying pip.egg-info/SOURCES.txt ->
build/bdist.macosx-10.6-intel/egg/EGG-INFO copying
pip.egg-info/dependency_links.txt ->
build/bdist.macosx-10.6-intel/egg/EGG-INFO copying
pip.egg-info/entry_points.txt ->
build/bdist.macosx-10.6-intel/egg/EGG-INFO copying
pip.egg-info/not-zip-safe ->
build/bdist.macosx-10.6-intel/egg/EGG-INFO copying
pip.egg-info/requires.txt ->
build/bdist.macosx-10.6-intel/egg/EGG-INFO copying
pip.egg-info/top_level.txt ->
build/bdist.macosx-10.6-intel/egg/EGG-INFO creating
'dist/pip-1.4.1-py2.7.egg' and adding
'build/bdist.macosx-10.6-intel/egg' to it removing
'build/bdist.macosx-10.6-intel/egg' (and everything under it)
Processing pip-1.4.1-py2.7.egg removing
'/Users/dl/Library/Python/2.7/lib/python/site-packages/pip-1.4.1-py2.7.egg'
(and everything under it) creating
/Users/dl/Library/Python/2.7/lib/python/site-packages/pip-1.4.1-py2.7.egg
Extracting pip-1.4.1-py2.7.egg to
/Users/dl/Library/Python/2.7/lib/python/site-packages pip 1.4.1 is
already the active version in easy-install.pth Installing pip script
to /Users/dl/Library/Python/2.7/bin Installing pip-2.7 script to
/Users/dl/Library/Python/2.7/bin

Installed
/Users/dl/Library/Python/2.7/lib/python/site-packages/pip-1.4.1-py2.7.egg
Processing dependencies for pip==1.4.1 Finished processing
dependencies for pip==1.4.1

Poi ho inserito pip install, il messaggio di errore è apparso così

Traceback (most recent call last):   File
"/Library/Frameworks/Python.framework/Versions/2.7/bin/pip", line 9,
in <module>
load_entry_point('pip==1.4.1', 'console_scripts', 'pip')()   File "build/bdist.macosx-10.6-intel/egg/pkg_resources.py", line 357, in
load_entry_point   File
"build/bdist.macosx-10.6-intel/egg/pkg_resources.py", line 2394, in
load_entry_point   File
"build/bdist.macosx-10.6-intel/egg/pkg_resources.py", line 2108, in
load ImportError: No module named pip

Qualcuno che ha incontrato lo stesso problema prima e può darmi qualche consiglio per risolverlo?


Cosa succede quando esegui pip install dal terminale (non interprete Python)
— TheoretiCAL

Il terminale mostra un errore del tipo "Errore di importazione: nessun modulo denominato pip"
— David Lu

Ho risposto alla stessa domanda dopo l'aggiornamento di MacOSX. finalmente ho scoperto di aver installato pip fallito. Reinstallare pip e quindi risolverlo.
— BollMose

si potrebbe fare riferimento stackoverflow.com/questions/10061039/...
— Jichao

Sembra che non sarà una soluzione per te, ma provo sempre questo comando quando ho qualche problema con pippython -m pip install <package>
— MartinP

Risposte:


176

Ho avuto lo stesso problema. La mia soluzione:

Per Python 3

sudo apt-get install python3-pip

Per Python 2

sudo apt-get install python-pip

61
la domanda riguarda l'installazione su Mac.
— Corey Goldberg

2
Su Arch ho dovuto installare python2-pip, python-pip ha indicato python3
— Florian Brinker

1
OMG grazie! Ho una scatola vagabonda con python 3 e mi chiedevo perché i comandi pip non funzionassero quando ho installato pip tramite 'sudo apt-get install python-pip'. Queste modifiche al controllo delle versioni (ad esempio php con homebrew) mi fanno impazzire a volte ...
— Ryan Coolwebs

100

Su Mac l'utilizzo di brew è un'opzione migliore in quanto apt-get non è disponibile. Comando:

Nel caso in cui sulla macchina siano installati sia python2 che python3

python2.7 -m ensurepip --default-pip

semplicemente dovrebbe risolvere il problema.

Se invece ti manca pip da python 3, python2.7passa semplicemente a python3nel comando sopra.


1
Oh finalmente una soluzione funzionante! Grazie! Avevo bisogno di python3 su Mac (Mac OS X 10.13.4). Dopo aver installato Python con Brew, brew install python il pip non è stato trovato: è python3 -m pip install redisrisultato che pip non è stato trovato. Seguendo il tuo approccio (python3 -m ...) ha funzionato.
— Raipe

1
Sto avendo python2 e 3 sulla stessa macchina ma per ora volevo usare Python3. Quindi ho dovuto modificare il commento sopra in sudo python3 -m pip install matplotlib(dovevo farlo tramite sudo, altrimenti alcuni permessi di cartella non funzionavano). (modificato la risposta in modo corrispondente)
— SCBuergel.eth

44

Dopo aver installato ez_setup , dovresti avere a easy_installdisposizione. Per installare pipbasta fare:

easy_install pip

questo ha reinstallato solo pip su python3. che ne dici di riparare l'installazione di pip in python 2.7.x?
— winux

Funziona anche per Windows ... Grazie!
— ZE Nir

33

Con macOS 10.15 e Homebrew 2.1.6 ricevevo questo errore con Python 3.7. Avevo solo bisogno di correre:

python3 -m ensurepip

Ora python3 -m pipfunziona per me.


1
In Ubuntu ottengo "surepip è disabilitato in Debian / Ubuntu per il sistema python". Ho risolto consudo apt install python3-pip
— tuxErrante


5

Ho riscontrato lo stesso problema quando ho tentato di installare il client nova.

spencers-macbook-pro:python-novaclient root# python  setup.py install    
running install
/usr/bin/python: No module named pip
error: /usr/bin/python -m pip.__init__ install   'pbr>=0.5.21,<1.0' 'iso8601>=0.1.4' 'PrettyTable>=0.6,<0.8' 'requests>=1.1' 'simplejson>=2.0.9' 'six' 'Babel>=0.9.6' returned 1

Uso homebrew quindi ho aggirato il problema con sudo easy_install pip

spencers-macbook-pro:python-novaclient root# brew search pip
aespipe     brew-pip    lesspipe    pipebench   pipemeter   spiped  pipeviewer

If you meant "pip" precisely:

Homebrew provides pip via: `brew install python`. However you will then
have two Pythons installed on your Mac, so alternatively you can:
    sudo easy_install pip
spencers-macbook-pro:python-novaclient root# sudo easy_install pip

I comandi dovrebbero essere simili se usi macports.


5

Penso che nessuna di queste risposte sopra possa risolvere il tuo problema.

Una volta sono stato anche confuso da questo problema. È necessario installare manualmente pipseguendo l' installazione pip della guida ufficiale (che attualmente prevede l'esecuzione di un singolo get-pip.pyscript Python )

dopo di che, solo sudo pip install Django. L'errore sparirà.


13
L'OP non ha menzionato Django da nessuna parte.
— dskrvk

3

So che questo thread è vecchio, ma ho risolto il problema per me stesso su OS X in modo diverso da quanto descritto qui.

Fondamentalmente ho reinstallato Python 2.7 tramite brew e viene fornito con pip.

Installa Xcode se non lo sei già:

xcode-select –install

Installa Brew come descritto qui :

ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

Quindi installa Python tramite Brew:

brew install python

E hai finito. Nel mio caso ho solo bisogno di installare pyserial.

pip install pyserial

1
Avevo già installato Xcode. Fatto ruby ...e brew .... Quando corro pip ...ho ottenuto -bash: pip: command not found. Qualche idea?
— questioni di significato


2

Nel terminale prova questo:

ls -lA /usr/local/bin | grep pip

nel mio caso ottengo:

-rwxr-xr-x 1 root  root      284 Сен 13 16:20 pip
-rwxr-xr-x 1 root  root      204 Окт 27 16:37 pip2
-rwxr-xr-x 1 root  root      204 Окт 27 16:37 pip2.7
-rwxr-xr-x 1 root  root      292 Сен 13 16:20 pip-3.4

Quindi pip2 || pip2.7 nel mio caso funziona e pip


1

la mia versione py è 3.7.3 e questo cmd ha funzionato

python3.7 -m pip install requests

richiede la libreria - per recuperare i dati dalle API web.

Questo esegue il modulo pip e gli chiede di trovare la libreria delle richieste su PyPI.org (l'indice dei pacchetti Python) e installarla nel sistema locale in modo che diventi disponibile per l'importazione


0

Ho risolto un errore simile su Linux impostando PYTHONPATH nella posizione dei pacchetti del sito. Questo è stato dopo la corsa python get-pip.py --prefix /home/chet/pip.

[chet@rhel1 ~]$ ~/pip/bin/pip -V
Traceback (most recent call last):
  File "/home/chet/pip/bin/pip", line 7, in <module>
    from pip import main
ImportError: No module named pip

[chet@rhel1 ~]$ export PYTHONPATH=/home/chet/pip/lib/python2.6/site-packages

[chet@rhel1 ~]$ ~/pip/bin/pip -V
pip 9.0.1 from /home/chet/pip/lib/python2.6/site-packages (python 2.6)

0

Testato di seguito per Linux: puoi scaricare direttamente pip da https://pypi.org/simple/pip/ untar e usarlo direttamente con il tuo ultimo python.

tar -xvf  pip-0.2.tar.gz
cd pip-0.2

Controlla il contenuto.

anant$ ls
docs  pip.egg-info  pip-log.txt  pip.py  PKG-INFO  regen-docs  scripts  setup.cfg  setup.py  tests

Esegui direttamente:

anant$ python pip.py --help
Usage: pip.py COMMAND [OPTIONS]

Options:
  --version             show program's version number and exit
  -h, --help            show this help message and exit
  -E DIR, --environment=DIR
                        virtualenv environment to run pip in (either give the
                        interpreter or the environment base directory)
  -v, --verbose         Give more output
  -q, --quiet           Give less output
  --log=FILENAME        Log file where a complete (maximum verbosity) record
                        will be kept
  --proxy=PROXY         Specify a proxy in the form
                        user:passwd@proxy.server:port. Note that the
                        user:password@ is optional and required only if you
                        are behind an authenticated proxy.  If you provide
                        user@proxy.server:port then you will be prompted for a
                        password.
  --timeout=SECONDS     Set the socket timeout (default 15 seconds)

0

Ecco un set minimo di istruzioni per l'aggiornamento a Python 3 utilizzando MacPorts:

sudo port install py37-pip
sudo port select --set pip pip37
sudo port select --set pip3 pip37
sudo pip install numpy, scipy, matplotlib

Ho eseguito del vecchio codice e funziona di nuovo dopo questo aggiornamento.



0

Su una sorta di Linux come ubuntu, prima esegui apt-get update e poi prova a installare il pacchetto python-pip. senza apt-get update, potresti ricevere un errore come

E: Impossibile individuare il pacchetto python-pip

1.Aggiorna:

sudo apt-get update

2.Installare il pacchetto pip

Per python2

sudo apt-get install python-pip

o

Per python3

sudo apt-get install python3-pip

E fatto!


1
Per alcuni tipi di Linux.
— Greg Allen,

@Greg Sì, è chiaramente indicato che potresti ricevere un errore, non che riceverai un errore.
— ANUP SAJJAN

Non so cosa stai indicando? Ma ho aggiornato la risposta.
— ANUP SAJJAN
Utilizzando il nostro sito, riconosci di aver letto e compreso le nostre Informativa sui cookie e Informativa sulla privacy.
Licensed under cc by-sa 3.0 with attribution required.