Pyinstaller和Ply IOError:源代码不可用 [英] Pyinstaller and Ply IOError: source code not available

查看:174
本文介绍了Pyinstaller和Ply IOError:源代码不可用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对pyinstaller来说还很陌生,但是现在已经有两天时间我一直在努力解决这个问题,而我似乎无法弄清楚出了什么问题.我的脚本可以正常运行,但是当我尝试使用pyinstaller进行构建时会引发IOerror,我的模块(包括ply.lex)似乎已包括在内,但也许我是个白痴?如果有人有任何建议,将不胜感激...

I am pretty new to pyinstaller but I have been banging my head against this problem for a couple of days now and I can't seem to figure out what's wrong. My script runs fine normally but throws IOerror when i try to build with pyinstaller, my modules (including ply.lex) seem to be included but maybe i'm being an idiot? If anyone has any advice it would be much appreciated...

这是我的错误(第65行是构建词法分析器的地方)

Here's my error (line 65 is where my lexer is built)

  Traceback (most recent call last):
  File "<string>", line 65, in <module>
  File "site-packages/ply/lex.py", line 906, in lex
  File "site-packages/ply/lex.py", line 580, in validate_all
  File "site-packages/ply/lex.py", line 822, in validate_rules
  File "site-packages/ply/lex.py", line 833, in validate_module
  File "inspect.py", line 690, in getsourcelines
  File "inspect.py", line 529, in findsource
IOError: source code not available

如果有人以前曾见过此问题,或者可以帮助您,那就太好了.

If anyone has seen this problem before, or can help that would be awesome.

推荐答案

PLY坚持在文件中定义其语法.具有名称和所有内容的真实文件.我认为这是因为它的策略是缓存计算出的语法表,该策略涉及将缓存的表的时间戳与原始文件的时间戳进行比较.

PLY insists that its grammars be defined in files. Real files, with names and everything. I think that's because of its strategy to cache the computed grammar tables, which involves comparing the timestamp of the cached tables with the timestamp of the original file.

Pyinstaller正在将语法评估为<string>,因为它是从存档而非文件中提取的. (Pyinstaller手册提到对于冻结的应用程序未正确设置__file__,这就是PLY正在查看的内容.)您可以在创建安装程序捆绑包时尝试使用--onedir选项,但是当然有一点点不同的行为.

Pyinstaller is, apparently, evaluating the grammar as a <string>, since it is extracted from an archive rather than being a file. (The Pyinstaller manual mentions that __file__ is not correctly set for the frozen application, and that is what PLY is looking at.) You might try using the --onedir option when you create your installer bundle, but of course that has slightly different behaviour.

这篇关于Pyinstaller和Ply IOError:源代码不可用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆