简体   繁体   English

使用 pip 安装后,jupyter Notebook 中没有名为“pydotplus”的模块

[英]No module named 'pydotplus' in jupyter Notebook after installing it using pip

I am running a code in jupyter Notebook an i got this error for import pydotplus : ModuleNotFoundError: No module named 'pydotplus'我在 jupyter Notebook 中运行代码,但我在import pydotplus遇到此错误: ModuleNotFoundError: No module named 'pydotplus'

However after trying to install using this command: !pip install pydotplus --user I still have the same error, it is not resolved.但是,在尝试使用此命令安装后: !pip install pydotplus --user我仍然有同样的错误,它没有解决。 Noting that I could not install pydotplus using the following command: !pip install pydotplus注意到我无法使用以下命令安装pydotplus!pip install pydotplus

I also tried import sys !{sys.executable} -m pip install <package_name> after reading that it must be installed globally this way, but I got an error saying: 'C:\Program' is not recognized as an internal or external command, operable program or batch file我也尝试过import sys !{sys.executable} -m pip install <package_name>在读到它必须以这种方式全局安装后,但我收到一条错误消息: 'C:\Program' is not recognized as an internal or external command, operable program or batch file

I would appreciate any help.我将不胜感激任何帮助。 Thanks :)谢谢 :)

Try inside a new cell in your notebook the following:在笔记本的新单元格中尝试以下操作:

%pip install pydotplus

Restart the kernel and see if the import now works.重新启动内核并查看导入现在是否有效。

The modern magics, %pip install and %conda install , are the way to install things to the environment backing the notebook being run, see here .现代魔法%pip install%conda install是将东西安装到支持正在运行的笔记本的环境的方法,请参见此处 Anything showing an exclamation point along with pip and conda is outdated.任何显示感叹号以及pipconda的内容都已过时。 The magics were added because using pip and conda with an exclamation point caused people all sorts of problems in the past when they don't understand environments.添加魔法是因为使用带有感叹号的pipconda会导致人们在过去不了解环境时出现各种问题。 With the modern magics this gets handled better without the user needing to know much about environments or how the !使用现代魔法,这可以更好地处理,而用户无需了解环境或如何! in front of a shell command opens a separate temporary shell instance aside from the notebook.在 shell 命令前面打开一个单独的临时 shell 实例,而不是笔记本。

Also because usually automagics are on by default in most modern Jupyter, you can usually leave of the % symbol from in front of pip and conda and behind-the-scenes the proper equivalent of the magics commands will now get used.此外,因为在大多数现代 Jupyter 中通常默认情况下自动打开魔法,您通常可以在pipconda前面留下%符号,而在幕后,现在将使用正确等效的魔法命令。 In other words, avoid the exclamation point in combination with pip or conda now.换句话说,现在避免将感叹号与pipconda结合使用。

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

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