简体   繁体   English

python:可以从命令行导入包,但不能从 jupyter notebook

[英]python: can improt package from command line but not from jupyter notebook

I've gotten a problem where I'm trying to import the tabula package into jupyter notebooks.我在尝试将 tabula 包导入 jupyter 笔记本时遇到问题。 I activated my conda virtual environment, pip installed tabula-py, and ran pip freeze .我激活了我的 conda 虚拟环境,pip 安装了 tabula-py,然后运行了pip freeze It confirmed that tabula-py was installed.它确认安装了 tabula-py。

certifi==2021.5.30
distro==1.6.0
et-xmlfile==1.1.0
greenlet==1.1.0
importlib-metadata==4.6.1
keyring==23.0.1
numpy==1.21.1
openpyxl==3.0.7
pandas==1.3.0
pyodbc==4.0.31
python-dateutil==2.8.2
pytz==2021.1
pywin32-ctypes==0.2.0
six==1.16.0
SQLAlchemy==1.4.21
tabula-py==2.3.0
wincertstore==0.2
XlsxWriter==1.4.4
zipp==3.5.0

While my virtual environment was active, I tested out importing the tabula package from the command line ( import tabula ).当我的虚拟环境处于活动状态时,我测试了从命令行导入 tabula 包 ( import tabula )。 Everything works!一切正常! I run exit() to get out of the python instance, then run jupyter notebook to bring up a jupyter notebook.我运行exit() python 实例,然后运行jupyter notebook以打开一个 jupyter notebook。 (still in my virtual environment) (仍在我的虚拟环境中)

However, in jupyter my import statement no longer works, even though i didn't change anything.但是,在 jupyter 中,即使我没有更改任何内容,我的导入语句也不再有效。 I run help('modules') within jupyter, and now tabula doesn't exist in my list of packages????我在 jupyter 中运行help('modules') ,现在我的包列表中不存在 tabula???? I'm not sure why it isn't working.我不确定为什么它不起作用。 I have the Java PATH set, and it works fine everywhere except jupyter notebook.我设置了 Java PATH,除了 jupyter notebook 之外,它在任何地方都可以正常工作。

Try run this command:尝试运行此命令:

!pip install tabula

After this try to import it and see if it works在此之后尝试导入它并查看它是否有效

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM