无法运行pycparser

时间:2017-10-31 05:51:28

标签: pycparser

我试图从pycparser开始尝试运行github repo上给出的示例。在本地保存示例c文件后,我只更改了要解析的文件的路径。我收到以下错误,并且不确定是否存在一些我遗漏的预处理步骤?

File "D:\Anaconda3\lib\site-packages\spyderlib\widgets\externalshell\sitecustomize.py", line 714, in runfile
execfile(filename, namespace)
  File "D:\Anaconda3\lib\site-packages\spyderlib\widgets\externalshell\sitecustomize.py", line 89, in execfile
exec(compile(f.read(), filename, 'exec'), namespace)
  File "C:/Users/Z003RTRP/Desktop/cparse.py", line 20, in <module>
ast = parse_file(filename, use_cpp=True, cpp_path='gcc', cpp_args=r'-Iutils/fake_libc_include')
  File "D:\Anaconda3\lib\site-packages\pycparser\__init__.py", line 86, in parse_file
text = preprocess_file(filename, cpp_path, cpp_args)
  File "D:\Anaconda3\lib\site-packages\pycparser\__init__.py", line 49, in preprocess_file
('Original error: %s' % e))
RuntimeError: Unable to invoke 'cpp'.  Make sure its path was passed correctly
Original error: [WinError 2] The system cannot find the file specified

1 个答案:

答案 0 :(得分:0)

看看this section of the README - 您必须将cpp_path指向系统上的C预处理器。对于Windows,它建议下载Clang的二进制版本并使用clang -E