无法 运行 pycparser 的基本示例
Not able to run basic example of 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
看看 this section of the README - 您必须将 cpp_path
指向您系统上的 C 预处理器。对于 Windows,建议下载 Clang 的二进制版本并使用 clang -E
我正在尝试从 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
看看 this section of the README - 您必须将 cpp_path
指向您系统上的 C 预处理器。对于 Windows,建议下载 Clang 的二进制版本并使用 clang -E