Failed to import pydot 및 graphviz error: (2,'RegOpenKeyEx', 오류 요약
9603 단어 Graphviztheanopydotdot-parser
import theano
import theano.tensor as T
from theano import function
import pydot
a = theano.tensor.vector("a") # declare symbolic variable
b = a + a ** 10 # build symbolic expression
f = theano.function([a], b) # compile function
print f([0, 1, 2]) # prints `array([0,2,1026])`
[ 0., 2., 1026.]
theano.printing.pydotprint(b, outfile="./pics/symbolic_graph_unopt.png", var_with_name_simple=True)
theano.printing.pydotprint(f, outfile="./pics/symbolic_graph_opt.png", var_with_name_simple=True)
error1:
Failed to import pydot
해결 방법: pip로pydot와graphviz를 설치하고 윈도우즈 플랫폼에서 msi파일을 다운로드하여 수동으로 설치해야 합니다.graphviz 다운로드 주소:https://pypi.python.org/pypi/graphviz/0.3.3
pyparsing 재설치:
pip uninstall pyparsing
pip install -Iv https://pypi.python.org/packages/source/p/pyparsing/pyparsing-1.5.7.tar.gz#md5=9be0fcdcc595199c646ab317c1d9a709
pip install pydot
pydot과 graphviz가 성공적으로 설치되었는지 테스트합니다.
import pydot
print pydot.find_graphviz()
None으로 돌아가면,pydot에서graphviz를 찾을 수 없음,error2 해결 방법을 보십시오.
error2:
graphviz error: (2, 'RegOpenKeyEx'...
pydot에서graphviz를 찾을 수 없습니다.pydot을 수동으로 수정합니다.find_graphviz () 함수, 예를 들어 나는 이렇게 고쳤다.
def find_graphviz():
"""Locate Graphviz's executables in the system. Tries three methods: First: Windows Registry (Windows only) This requires Mark Hammond's pywin32 is installed. Secondly: Search the path It will look for 'dot', 'twopi' and 'neato' in all the directories specified in the PATH environment variable. Thirdly: Default install location (Windows only) It will look for 'dot', 'twopi' and 'neato' in the default install location under the "Program Files" directory. It will return a dictionary containing the program names as keys and their paths as values. If this fails, it returns None. """
# Method 1 (Windows only)
#
#======================= , if graphviz ================
# if os.sys.platform == 'win32':
#
# try:
# import win32api, win32con
#
# # Get the GraphViz install path from the registry
# #
# hkey = win32api.RegOpenKeyEx( win32con.HKEY_LOCAL_MACHINE,
# "SOFTWARE\ATT\Graphviz", 0, win32con.KEY_QUERY_VALUE )
#
# path = win32api.RegQueryValueEx( hkey, "InstallPath" )[0]
# win32api.RegCloseKey( hkey )
#
# # Now append the "bin" subdirectory:
# #
# path = os.path.join(path, "bin")
# progs = __find_executables(path)
# if progs is not None :
# #print "Used Windows registry"
# return progs
#
# except ImportError :
# # Print a messaged suggesting they install these?
# #
# pass
#
#==============================================================================
# Method 2 (Linux, Windows etc)
#
if os.environ.has_key('PATH'):
for path in os.environ['PATH'].split(os.pathsep):
progs = __find_executables(path)
if progs is not None :
#print "Used path"
return progs
# Method 3 (Windows only)
#
if os.sys.platform == 'win32':
# Try and work out the equivalent of "C:\Program Files" on this
# machine (might be on drive D:, or in a different language)
#
if os.environ.has_key('PROGRAMFILES'):
# Note, we could also use the win32api to get this
# information, but win32api may not be installed.
path = os.path.join(os.environ['PROGRAMFILES'], 'ATT', 'GraphViz', 'bin')
else:
#Just in case, try the default...
path = r"D:\deeplearning\graphviz\bin"
progs = __find_executables(path)
if progs is not None :
#print "Used default install location"
return progs
# ,path graphviz
path = r"D:\xxx\graphviz\bin"
progs = __find_executables(path)
if progs is not None :
#print "Used default install location"
return progs
for path in (
'/usr/bin', '/usr/local/bin',
'/opt/bin', '/sw/bin', '/usr/share',
'/Applications/Graphviz.app/Contents/MacOS/' ):
progs = __find_executables(path)
if progs is not None :
#print "Used path"
return progs
# Failed to find GraphViz
#
return None
참고 자료:
GraphViz’s executables not found on Windows 7 64-bit if user installs them in a custom directory #91:https://github.com/erocarrera/pydot/issues/91
pydot and graphviz error: Couldn’t import dot_parser, loading of dot files will not be possible:http://stackoverflow.com/questions/15951748/pydot-and-graphviz-error-couldnt-import-dot-parser-loading-of-dot-files-will
RuntimeError: Failed to import pydot. #1801:https://github.com/Theano/Theano/issues/1801
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
macbook pro 2020(intel)에 graphviz를 넣으려고 하면 에러 토했기 때문에 해결해 보았다vscode에서 plantUML을 사용하려고 생각하고, 확장 기능을 넣어 놀고 있었을 때, 클래스 다이어그램에서 클래스를 2개 이상 만들면 에러를 토했기 때문에 해결책으로서 graphviz를 넣기로 했습니다. 실행....
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.