即使安装 graphviz 并确保目录中存在 cgraph.h 后,我也无法安装 pygraphviz。
我还手动指定了安装目录。例如安装路径
致命错误 C1083:无法打开包含文件:'graphviz/cgraph.h':没有这样的文件或目录
寻找任何和所有建议。使用Windows。
C:\Users\mmcgown\Desktop\School\MSDS452\pygraphviz-1.5>python setup.py install --prefix=C:\Program_Files_(x86)\Graphviz2.38 --include-path=C:\Program_Files_(x86)\Graphviz2.38\include\ --library-path=C:\Program_Files_(x86)\Graphviz2.38\lib\
Run Code Online (Sandbox Code Playgroud)
running install
running build
running build_py
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 files found matching '*.png' under directory 'doc'
warning: no files found matching '*.html' under directory 'doc'
warning: no files found matching '*.txt' under directory 'doc'
warning: no files found matching '*.css' under directory 'doc'
warning: …Run Code Online (Sandbox Code Playgroud) 我正在努力准备面试,并想为句子中每个字母的计数制作一本字典。
我很惊讶地发现我可能存在范围界定问题,或者看起来像是问题。
对于下面的具体方法,我不确定为什么它不起作用,直到我发现 elem 在 while 循环中被设置为空。但由于它嵌套在引用 elem 的 for 循环中,我不确定为什么会发生这种情况。
s = 'letters and stuff'
def d_count(s):
dic = {}
i = 0
s1 = set(s)
s2 = list(s)
for elem in s1:
dic[elem] = 0
j = 0
while (i < len(s2)):
#elem disappears here
if s2[i] == elem:
j = j+1
dic[elem] = j
i = i + 1
return dic
print(d_count(s))
Run Code Online (Sandbox Code Playgroud)
结果
{' ': 2, 's': 0, 'n': 0, 'u': 0, 'l': 0, 'f': 0, 'd': …Run Code Online (Sandbox Code Playgroud)