anaconda3 graphviz - ModuleNotFoundError: нет модуля с именем «pygraphviz» - PullRequest
0 голосов
/ 04 мая 2018

Я пытаюсь запустить визуализацию историй (Раса), используя graphviz

Я использую Windows 10, PyCharm, Anaconda3, Python3.6

Я попытался найти решение об установке graphviz и pygraphviz

First solution (doesn't solve the following errors):
1a. conda update matplotlib
1b. conda install -c anaconda graphviz
1c. conda install -c anaconda python-graphviz

Second solution (doesn't solve the following errors):
1 . Download and install graphviz-2.38.msi from 
https://graphviz.gitlab.io/_pages/Download/Download_windows.html
2 . Set the path variable
(a) Control Panel > System and Security > System > Advanced System Settings > Environment Variables > Path > Edit
(b) add 'C:\Program Files (x86)\Graphviz2.38\bin'
3. run python -m pip install graphviz
4. run python -m pip install git+https://github.com/pygraphviz/pygraphviz.git --install-option="--include-path=/usr/include/graphviz" --install-option="--library-path=/usr/lib/graphviz/"

Тогда возвращается

Failed building wheel for pygraphviz
Running setup.py clean for pygraphviz
Failed to build pygraphviz
Installing collected packages: pygraphviz
Running setup.py install for pygraphviz ... error
Complete output from command C:\Users\xxxx\Anaconda3\python.exe -u -c "import setuptools, tokenize;__file__='C:\\Users\\xxxx\\AppData\\Local\\Temp\\pip-req-build-kh81ij8k\\setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record C:\Users\xxxx\AppData\Local\Temp\pip-record-82zdsb0t\install-record.txt --single-version-externally-managed --compile --include-path=/usr/include/graphviz --library-path=/usr/lib/graphviz/:
C:\Users\xxxx\Anaconda3\lib\site-packages\setuptools\dist.py:355: UserWarning: Normalizing '1.5.dev' to '1.5.dev0'
  normalized_version,
running install
running build
running build_py
creating build
creating build\lib.win-amd64-3.6
creating build\lib.win-amd64-3.6\pygraphviz
copying pygraphviz\agraph.py -> build\lib.win-amd64-3.6\pygraphviz
copying pygraphviz\graphviz.py -> build\lib.win-amd64-3.6\pygraphviz
copying pygraphviz\release.py -> build\lib.win-amd64-3.6\pygraphviz
copying pygraphviz\version.py -> build\lib.win-amd64-3.6\pygraphviz
copying pygraphviz\__init__.py -> build\lib.win-amd64-3.6\pygraphviz
creating build\lib.win-amd64-3.6\pygraphviz\tests
copying pygraphviz\tests\test.py -> build\lib.win-amd64-3.6\pygraphviz\tests
copying pygraphviz\tests\test_attributes.py -> build\lib.win-amd64-3.6\pygraphviz\tests
copying pygraphviz\tests\test_attribute_defaults.py -> build\lib.win-amd64-3.6\pygraphviz\tests
copying pygraphviz\tests\test_clear.py -> build\lib.win-amd64-3.6\pygraphviz\tests
copying pygraphviz\tests\test_drawing.py -> build\lib.win-amd64-3.6\pygraphviz\tests
copying pygraphviz\tests\test_edge_attributes.py -> build\lib.win-amd64-3.6\pygraphviz\tests
copying pygraphviz\tests\test_graph.py -> build\lib.win-amd64-3.6\pygraphviz\tests
copying pygraphviz\tests\test_html.py -> build\lib.win-amd64-3.6\pygraphviz\tests
copying pygraphviz\tests\test_layout.py -> build\lib.win-amd64-3.6\pygraphviz\tests
copying pygraphviz\tests\test_node_attributes.py -> build\lib.win-amd64-3.6\pygraphviz\tests
copying pygraphviz\tests\test_readwrite.py -> build\lib.win-amd64-3.6\pygraphviz\tests
copying pygraphviz\tests\test_setup.py -> build\lib.win-amd64-3.6\pygraphviz\tests
copying pygraphviz\tests\test_string.py -> build\lib.win-amd64-3.6\pygraphviz\tests
copying pygraphviz\tests\test_subgraph.py -> build\lib.win-amd64-3.6\pygraphviz\tests
copying pygraphviz\tests\test_unicode.py -> build\lib.win-amd64-3.6\pygraphviz\tests
copying pygraphviz\tests\__init__.py -> build\lib.win-amd64-3.6\pygraphviz\tests
running egg_info
writing pygraphviz.egg-info\PKG-INFO
writing dependency_links to pygraphviz.egg-info\dependency_links.txt
writing top-level names to pygraphviz.egg-info\top_level.txt
reading manifest file 'pygraphviz.egg-info\SOURCES.txt'
reading manifest template 'MANIFEST.in'
warning: no previously-included files matching '*~' found anywhere in distribution
warning: no previously-included files matching '*.pyc' found anywhere in distribution
warning: no previously-included files matching '.svn' found anywhere in distribution
no previously-included directories found matching 'doc\build'
writing manifest file 'pygraphviz.egg-info\SOURCES.txt'
copying pygraphviz\graphviz.i -> build\lib.win-amd64-3.6\pygraphviz
copying pygraphviz\graphviz_wrap.c -> build\lib.win-amd64-3.6\pygraphviz
running build_ext
building 'pygraphviz._graphviz' extension
creating build\temp.win-amd64-3.6
creating build\temp.win-amd64-3.6\Release
creating build\temp.win-amd64-3.6\Release\pygraphviz
C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Tools\MSVC\14.13.26128\bin\HostX86\x64\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -I/usr/include/graphviz -IC:\Users\xxxx\Anaconda3\include -IC:\Users\e8180\Anaconda3\include "-IC:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Tools\MSVC\14.13.26128\include" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.16299.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.16299.0\shared" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.16299.0\um" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.16299.0\winrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.16299.0\cppwinrt" /Tcpygraphviz/graphviz_wrap.c /Fobuild\temp.win-amd64-3.6\Release\pygraphviz/graphviz_wrap.obj
graphviz_wrap.c
pygraphviz/graphviz_wrap.c(2987): fatal error C1083: Cannot open include file: 'graphviz/cgraph.h': No such file or directory
error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\BuildTools\\VC\\Tools\\MSVC\\14.13.26128\\bin\\HostX86\\x64\\cl.exe' failed with exit status 2

----------------------------------------
Command "C:\Users\xxxx\Anaconda3\python.exe -u -c "import setuptools, tokenize;__file__='C:\\Users\\xxxx\\AppData\\Local\\Temp\\pip-req-build-kh81ij8k\\setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record C:\Users\xxxx\AppData\Local\Temp\pip-record-82zdsb0t\install-record.txt --single-version-externally-managed --compile --include-path=/usr/include/graphviz --library-path=/usr/lib/graphviz/" failed with error code 1 in C:\Users\xxxx\AppData\Local\Temp\pip-req-build-kh81ij8k\

Я запускаю этот код или команду для визуализации:

Команда:

python -m rasa_core.visualize -d domain.yml -s data/stories.md -o graph.png

Код:

from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals
from rasa_core.agent import Agent
from rasa_core.policies.keras_policy import KerasPolicy
from rasa_core.policies.memoization import MemoizationPolicy

if __name__ == '__main__':
    agent = Agent("domain.yml",
                  policies=[MemoizationPolicy(), KerasPolicy()])

    agent.visualize("data/stories.md",
                    output_file="graph.png", max_history=2)

Но он возвращает эти ошибки:

C:\Users\xxxx\Anaconda3\lib\site-packages\h5py\__init__.py:36: FutureWarning: Conversion of the second argument of issubdtype from `float` to `np.floating` is deprecated. In future, it will be treated as `np.float64 == np.dtype(float).type`.
  from ._conv import register_converters as _register_converters
Using TensorFlow backend.
Processed Story Blocks: 100%|██████████| 4/4 [00:00<00:00, 1329.31it/s, # 
trackers=1, samples=24]
Processed Story Blocks: 100%|██████████| 4/4 [00:00<00:00, 3988.88it/s]
Processed Story Blocks: 100%|██████████| 4/4 [00:00<00:00, 3982.25it/s]
Traceback (most recent call last):
  File "C:\Users\xxxx\Anaconda3\lib\site-packages\networkx\drawing\nx_agraph.py", line 135, in to_agraph
import pygraphviz
ModuleNotFoundError: No module named 'pygraphviz'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:/Users/xxxx/Documents/sfu/py_rasabot/moodbot/visualize.py", line 16, in <module>
output_file="graph.png", max_history=2)
  File "C:\Users\xxxx\Anaconda3\lib\site-packages\rasa_core\agent.py", line 206, in visualize
self.interpreter, nlu_training_data, fontsize)
  File "C:\Users\xxxx\Anaconda3\lib\site-packages\rasa_core\training\visualization.py", line 316, in visualize_stories
persist_graph(G, output_file)
  File "C:\Users\xxxx\Anaconda3\lib\site-packages\rasa_core\training\visualization.py", line 221, in persist_graph
A = nx.nx_agraph.to_agraph(G)  # convert to a graphviz graph
  File "C:\Users\xxxx\Anaconda3\lib\site-packages\networkx\drawing\nx_agraph.py", line 138, in to_agraph
'http://pygraphviz.github.io/')
ImportError: ('requires pygraphviz ', 'http://pygraphviz.github.io/')
...