Python 导入错误:没有名为 pydot 的模块(无法导入 pydot)
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/35177262/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
ImportError: No module named pydot ( unable to import pydot)
提问by Sanchit Aluna
采纳答案by Eugenie
pip install pydot
pip install graphviz
there is a similar problemm: Keras: "RuntimeError: Failed to import pydot." after installing graphviz and pydot
有一个类似的问题: Keras:“运行时错误:无法导入 pydot。” 安装graphviz和pydot后
pip
installs pydot
, but not GraphViz. The GraphViz binary files (dot
, neato
, etc.) need to be downloaded and installed separately from pydot
. In addition, the location of these executables should be added to the $PATH
environment variable (or equivalent in your operating system). Otherwise pydot
won't find dot
when looking in directories included in the current path.
pip
安装pydot
,但不是 GraphViz。GraphViz 二进制文件(dot
、neato
等)需要与pydot
. 此外,应将这些可执行文件的位置添加到$PATH
环境变量(或操作系统中的等效变量)中。否则在查看当前路径中包含的目录时pydot
将找不到dot
。
回答by JRazor
Try to command line with:
尝试命令行:
import pydot
If you get ImportError
, just reinstall this module.
如果你得到ImportError
,只需重新安装这个模块。
Maybe you have multiple installations of Python (e.g. 2.7 and 3.5). When installing you put the module in one Python and try to import in another.
也许您安装了多个 Python(例如 2.7 和 3.5)。安装时,将模块放在一个 Python 中,然后尝试导入另一个。
Also, this problem can to occur due to the fact that instead install you just copied the file to your local directory. If yes, use pip
or setuptools
for install or add your local directory to sys.path
.
此外,由于安装时您只是将文件复制到本地目录,因此可能会发生此问题。如果是,请使用pip
或setuptools
进行安装或将本地目录添加到sys.path
.
回答by Chen Xu
Do you not know how to install pydot in python spyder? If you use Spyder on Windows, you could try to input code following in CMD
( I have no idea whether it is effective on Linux):
不知道如何在python spyder中安装pydot?如果你在 Windows 上使用 Spyder,你可以尝试输入以下代码CMD
(我不知道它在 Linux 上是否有效):
conda install -c https://conda.binstar.org/sstromberg pydot
If it says 'InvocationException: GraphViz's executables not found' after you install pydot, you need install GraphViz as well:
如果在安装 pydot 后显示“InvocationException: GraphViz's executables not found”,则还需要安装 GraphViz:
conda install GraphViz
回答by saneryee
You could install pydot
and pyparsing
using conda.
您可以安装pydot
和pyparsing
使用 conda。
conda install -c anaconda pydot=1.2.3
conda install -c anaconda pyparsing=2.2.0