2016-07-14 8 views
15

Jupiter Notebookで!pip install geocoderを実行すると、端末にpip install geocoderが実行されたと同じ出力が得られますが、インポートしようとするとジオコーダパッケージは利用できません。それをインポートしようと次にJupyterノートブック内からpipパッケージをインストールすると動作しない

!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 

import geocoder 

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

ImportError: No module named geocoder 

私も試した

私はUbuntuの14.04、アナコンダ4.0.0を使用して8.1.2

インストールジオコーダーのピップよノートブックをシャットダウンし、不運にも再起動します。

編集:端末を使って/home/ubuntu/.local/lib/python2.7/site-packagesにジオコーダーパッケージをインストールし、ノートブックを使用すると/ usr/local/lib/python2にインストールされていることがわかりました。 7/dist-packagesはパスに含まれていません。 sys.path.append('/usr/local/lib/python2.7/dist-packages')は、現在のセッションの問題を解決します。

パスを永続的に変更したり、ジオコーダーのインストール先を指示するにはどうすればよいですか?

+1

は、これらは、Python 2つのパッケージです。あなたのノートブックはPython 2カーネルまたはPython 3カーネルを使用していますか? – nitind

+0

Python 2 –

+0

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

答えて

0

は、いくつかのシェルの魔法を使用してみてください:%% SH %%sh pip install geocoder はそれが動作するかどうか私に知らせて、PIP2を使用したおかげで

-3

は私のために働いた:

!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> 

(シェルコマンドとしてセルを実行するためにノートブックを告げる「!」)

0

代替オプション: あなたも、bashのカーネルと、その後pip install geocoderを使用してjupyterにbashのセルを作成することができます。これは、Python 3.6の下でjupyterのノートブックで

1

を動作するはずです、次の行は動作します:

!source activate py36;pip install <...> 
関連する問題