为了安装cython(对于
python 2.7,windows 8.1),以.zip格式下载,解压缩整个文件并运行setup.py.因此,python shell显示了这个:
无法找到pgen,没有编译正式语法.
问题是什么以及如何解决?
最佳答案 setup.py中的相关代码首先尝试查找pgen
pgen = find_executable(
'pgen', os.pathsep.join([os.environ['PATH'], os.path.join(get_python_inc(), '..', 'Parser')]))
if not pgen:
print ("Unable to find pgen, not compiling formal grammar.")
如果找到pgen,则将文件Cython / Parser / Grammar作为pgen的参数给出
else:
parser_dir = os.path.join(os.path.dirname(__file__), 'Cython', 'Parser')
grammar = os.path.join(parser_dir, 'Grammar')
subprocess.check_call([
pgen,
os.path.join(grammar),
os.path.join(parser_dir, 'graminit.h'),
os.path.join(parser_dir, 'graminit.c'),
])
Cython / Parser / Grammar的第一行,
# Grammar for Cython, based on the Grammar for Python 3
# Note: This grammar is not yet used by the Cython parser and is subject to change.
该评论似乎暗示即使pgen可用,也不会使用它生成的代码.