python notebook软件_Python在Jupyter Notebook中看不到软件包

I use Jupyter Notebook with a virtual environment.

I have a dependency installed, but can't import it:

cell 1:

!pip3 install sent2vec

Requirement already satisfied: sent2vec in

venv/lib/python3.7/site-packages (0.0.0)

cell 2:

import sent2vec

ModuleNotFoundError Traceback (most recent call last)

in

----> 1 import sent2vec

ModuleNotFoundError: No module named 'sent2vec'

How this can happen? How to fix this?

> pip3 list

Package Version

------------ ---------

certifi 2019.9.11

chardet 3.0.4

Cython 0.29.14

idna 2.8

joblib 0.14.0

langdetect 1.0.7

nltk 3.4.4

numpy 1.17.1

pip 19.3.1

requests 2.22.0

scikit-learn 0.21.3

scipy 1.3.2

sent2vec 0.0.0

setuptools 41.6.0

six 1.13.0

urllib3 1.25.7

wheel 0.33.6

解决方案

You'll note that jupyter is not listed in your installed packages. That means you're running it from a different virtual environment. As I mentioned in the comment responding to your question, you can run which jupyter to find out where your Jupyter Notebook application is being run from (assuming you're on a *NIX system); in this case, it won't be from the python3.7 virtual environment that shows up in your first code block.

To resolve the issue, you simply need to run pip3 install jupyter, then retry running jupyter notebook.

Alternatively, you can add your virtual environment as a kernel so that it can be selected when you're running Jupyter from your original environment. To do this, you would run (assuming pip is connected to your original environment):

pip install ipykernel

ipython kernel install --user --name=

You should then be able to select that venv as a kernel on new notebooks. (Source for info on venv activation in Jupyter).

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值