无法在Jupyter Notebook中导入已安装的软件包

时间:2019-12-11 07:32:25

标签: python jupyter-notebook

如果我在Jupyter笔记本中运行以下命令:

!pip install gTTS

from gtts import gTTS 

我得到以下输出:

Requirement already satisfied: gTTS in c:\users\yatin\.conda\envs\gpu\lib\site-packages (2.0.4)
Requirement already satisfied: click in c:\users\yatin\.conda\envs\gpu\lib\site-packages (from gTTS) (7.0)
Requirement already satisfied: six in c:\users\yatin\.conda\envs\gpu\lib\site-packages (from gTTS) (1.13.0)
Requirement already satisfied: gtts-token>=1.1.3 in c:\users\yatin\.conda\envs\gpu\lib\site-packages (from gTTS) (1.1.3)
Requirement already satisfied: requests in c:\users\yatin\.conda\envs\gpu\lib\site-packages (from gTTS) (2.22.0)
Requirement already satisfied: beautifulsoup4 in c:\users\yatin\.conda\envs\gpu\lib\site-packages (from gTTS) (4.8.1)
Requirement already satisfied: chardet<3.1.0,>=3.0.2 in c:\users\yatin\.conda\envs\gpu\lib\site-packages (from requests->gTTS) (3.0.4)
Requirement already satisfied: certifi>=2017.4.17 in c:\users\yatin\.conda\envs\gpu\lib\site-packages (from requests->gTTS) (2019.11.28)
Requirement already satisfied: urllib3!=1.25.0,!=1.25.1,<1.26,>=1.21.1 in c:\users\yatin\.conda\envs\gpu\lib\site-packages (from requests->gTTS) (1.25.7)
Requirement already satisfied: idna<2.9,>=2.5 in c:\users\yatin\.conda\envs\gpu\lib\site-packages (from requests->gTTS) (2.8)
Requirement already satisfied: soupsieve>=1.2 in c:\users\yatin\.conda\envs\gpu\lib\site-packages (from beautifulsoup4->gTTS) (1.9.5)


ModuleNotFoundError: No module named 'gtts'

我该怎么办?

编辑:from gtts import gTTS在终端中运行良好。

2 个答案:

答案 0 :(得分:1)

尝试:

!conda install gTTS
from gtts import gTTS 

由于使用的是Conda,因此应使用conda而不是pip

答案 1 :(得分:0)

将安装版本pip安装到默认的python2版本python2,您应该这样做

!python3 -m pip install gTTS
from gtts import gTTs