Quando eseguo !pip install geocoder
in Jupyter Notebook ottengo lo stesso output di pip install geocoder
nel terminale ma il pacchetto geocoder non è disponibile quando provo a importarlo.Installazione di un pacchetto pip dall'interno di un Notebook Jupyter non funzionante
sto usando Ubuntu 14.04, Anaconda 4.0.0 e 8.1.2 pip
geocoder Installazione:
!pip install geocoder
The directory '/home/ubuntu/.cache/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
The directory '/home/ubuntu/.cache/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Collecting geocoder
Downloading geocoder-1.15.1-py2.py3-none-any.whl (195kB)
100% |████████████████████████████████| 204kB 3.2MB/s
Requirement already satisfied (use --upgrade to upgrade): requests in /usr/local/lib/python2.7/dist-packages (from geocoder)
Requirement already satisfied (use --upgrade to upgrade): ratelim in /usr/local/lib/python2.7/dist-packages (from geocoder)
Requirement already satisfied (use --upgrade to upgrade): six in /usr/local/lib/python2.7/dist-packages (from geocoder)
Requirement already satisfied (use --upgrade to upgrade): click in /usr/local/lib/python2.7/dist-packages (from geocoder)
Requirement already satisfied (use --upgrade to upgrade): decorator in /usr/local/lib/python2.7/dist-packages/decorator-4.0.10-py2.7.egg (from ratelim->geocoder)
Installing collected packages: geocoder
Successfully installed geocoder-1.15.1
quindi provare a importarlo:
import geocoder
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-4-603a981d39f2> in <module>()
----> 1 import geocoder
ImportError: No module named geocoder
Ho anche provato spegnere il notebook e riavviarlo senza fortuna.
Modifica: ho trovato che l'utilizzo del terminale installa il pacchetto geocoder in /home/ubuntu/.local/lib/python2.7/site-packages e l'utilizzo di un notebook lo installa in/usr/local/lib/python2. 7/dist-packages che non si trova nel percorso. sys.path.append('/usr/local/lib/python2.7/dist-packages')
risolve il problema per la sessione corrente.
Quindi, come posso modificare permanentemente il percorso o indicare a pip dove installare il geocoder?
Quelli sono Python 2 pacchetti. Il tuo notebook usa un kernel Python 2 o un kernel Python 3? – nitind
Utilizzo di Python 2 –
['PYTHONPATH'] (https://docs.python.org/2/using/cmdline.html#envvar-PYTHONPATH) – Alik