我正在运行一个需要pydot和graphviz的代码。我使用python3.5和ubuntu16.04LTS 64位。
File "/usr/local/lib/python3.5/dist-packages/keras/utils/vis_utils.py", line 17, in _check_pydot
raise ImportError('Failed to import pydot. You must install pydot'
ImportError: Failed to import pydot. You must install pydot and graphviz for `pydotprint` to work.我在googled上搜索了一下,然后发现我可以用代码pip install pydot安装pydot。但我知道这是个错误。我是乌本图的菜鸟,我不知道该怎么做。那么我该如何安装pydot呢?
deeplearning@deep-learning-virtual-machine:~$ pip install pydot
Collecting pydot
Collecting pyparsing>=2.1.4 (from pydot)
Using cached pyparsing-2.2.0-py2.py3-none-any.whl
Installing collected packages: pyparsing, pydot
Found existing installation: pyparsing 2.0.3
Uninstalling pyparsing-2.0.3:
Exception:
Traceback (most recent call last):
File "/usr/lib/python3.5/shutil.py", line 538, in move
os.rename(src, real_dst)
PermissionError: [Errno 13] Permission denied: '/usr/lib/python3/dist-packages/__pycache__/pyparsing.cpython-35.pyc' -> '/tmp/pip-45miiuxw-uninstall/usr/lib/python3/dist-packages/__pycache__/pyparsing.cpython-35.pyc'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/local/lib/python3.5/dist-packages/pip/basecommand.py", line 215, in main
status = self.run(options, args)
File "/usr/local/lib/python3.5/dist-packages/pip/commands/install.py", line 342, in run
prefix=options.prefix_path,
File "/usr/local/lib/python3.5/dist-packages/pip/req/req_set.py", line 778, in install
requirement.uninstall(auto_confirm=True)
File "/usr/local/lib/python3.5/dist-packages/pip/req/req_install.py", line 754, in uninstall
paths_to_remove.remove(auto_confirm)
File "/usr/local/lib/python3.5/dist-packages/pip/req/req_uninstall.py", line 115, in remove
renames(path, new_path)
File "/usr/local/lib/python3.5/dist-packages/pip/utils/__init__.py", line 267, in renames
shutil.move(old, new)
File "/usr/lib/python3.5/shutil.py", line 553, in move
os.unlink(src)
PermissionError: [Errno 13] Permission denied: '/usr/lib/python3/dist-packages/__pycache__/pyparsing.cpython-35.pyc'发布于 2017-05-20 07:03:47
python和graphviz在所有当前支持的Ubuntu版本中都是默认的Ubuntu存储库。在所有当前支持的Ubuntu版本中,打开终端并键入:
sudo apt install python-pydot python-pydot-ng graphviz # python-pydot-ng isn't in the 14.04 repos这个流程图是在Ubuntu中用graphviz创建的。因为graphviz使用内置的点编程语言(它包含在graphviz包中),所以链接流程图的源代码在任何文本编辑器中都是可编辑的,即使python没有安装。
我不知道当您可以从Ubuntu存储库中获得pip时,为什么要安装带有pip的pydot,但是为了回答您的问题,我尝试了在pip3 install pydot虚拟环境中安装pydot,它成功了,所以您可能需要用sudo -H pip3 install --upgrade pip更新pip到最新版本。我使用pip3而不是pip,因为您在问题中写到您使用的是Python3.5。
发布于 2017-05-20 07:14:44
因为您使用python 3,所以正确的命令应该是pip3 install pydot graphviz。您可以使用pip3安装sudo apt install python3-pip。
发布于 2018-03-28 02:40:29
在Ubuntu 17.10上,非政府组织解决了以下问题:
sudo apt-get install python3-pydot graphviz
sudo pip3 install pydot_nghttps://askubuntu.com/questions/917030
复制相似问题