2016-07-14 15 views
15

Po uruchomieniu !pip install geocoder w Notatniku Jupyter otrzymuję taki sam wynik, jak uruchomienie pip install geocoder w terminalu, ale pakiet geocoder nie jest dostępny, gdy próbuję go zaimportować.Instalowanie pakietu pip z Notatnika Japyter nie działa

Używam Ubuntu 14.04, Anaconda 4.0.0 i 8.1.2 pip

Instalacja geocoder:

!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 

Następnie spróbuj go importować:

import geocoder 

--------------------------------------------------------------------------- 
ImportError        Traceback (most recent call last) 
<ipython-input-4-603a981d39f2> in <module>() 
----> 1 import geocoder 

ImportError: No module named geocoder 

Próbowałem też zamknięcie notebooka i ponowne uruchomienie bez żadnego szczęścia.

Edycja: Znalazłem, że za pomocą terminala instaluję pakiet geocoder w /home/ubuntu/.local/lib/python2.7/site-packages i używając notebooka instaluję go w/usr/local/lib/python2. 7/dist-pakiety, których nie ma na ścieżce. sys.path.append('/usr/local/lib/python2.7/dist-packages') rozwiązuje problem dla bieżącej sesji.

Jak zatem trwale zmienić ścieżkę lub powiedzieć, gdzie można zainstalować geocoder?

+1

Są Python 2 pakiety. Czy twój notebook używa jądra Python 2 lub jądra Python 3? – nitind

+0

Używa Pythona 2 –

+0

['PYTHONPATH'] (https://docs.python.org/2/using/cmdline.html#envvar-PYTHONPATH) – Alik

Odpowiedz

0

Spróbuj użyć trochę powłoki Magic: %% sh %%sh pip install geocoder dać mi znać, jeśli działa, dzięki

-3

Korzystanie PIP2 pracował dla mnie:

!pip2 install geocoder 
... 
import geocoder 
g = geocoder.google('Mountain View, CA') 
g.latlng 
[37.3860517, -122.0838511] 
0
conda create -n py27 python=2.7 ipykernel 

source activate py27 

pip install geocoder 
9
! pip install --user <package> 

(! '' The opowiada notebooka do wykonywania komórkę jako polecenie shell)

0

opcja alternatywna: można również utworzyć komórkę bash w jupyter używając jądra bash i następnie pip install geocoder. To powinno działać

1

W jupyter notebooka pod Pythona 3.6, następujący wiersz działa:

!source activate py36;pip install <...> 
Powiązane problemy