Jupyter Notebook无法导入软件包Geopy

时间:2020-10-12 13:59:57

标签: python pip jupyter-notebook geopy

在Jupyter笔记本中工作,安装软件包geopy,然后重新启动内核。

import geopy
ModuleNotFoundError                       Traceback (most recent call last)
<ipython-input-5-99b9d2081153> in <module>
----> 1 import geopy

ModuleNotFoundError: No module named 'geopy

我可以通过运行以下命令来确认geopy(从Jupyter笔记本中)已被取消

!pip install  geopy
Requirement already satisfied: geopy in ./venv/lib/python3.8/site-packages (2.0.0)
Requirement already satisfied: geographiclib<2,>=1.49 in ./venv/lib/python3.8/site-packages (from geopy) (1.50)

如果可能有帮助:

!python -V
Python 3.8.3

!which python
/home/kabir/Desktop/dataset/venv/bin/python

这是怎么了?

2 个答案:

答案 0 :(得分:1)

尝试使用特定的pip来安装它,它与Jupyter中运行的当前Python内核相关联:

import sys
!{sys.executable} -m  pip install geopy

答案 1 :(得分:0)

在默认命令行和Jupyter笔记本中尝试以下命令。

which python

该路径应与Jupyter笔记本中的路径匹配,如果不匹配,则这是您的问题。