Python 2.7 ply.yacc 生成“无法获取源代码"pyinstaller 中的错误 [英] Python 2.7 ply.yacc generates "cannot get source" error in pyinstaller

查看:71
本文介绍了Python 2.7 ply.yacc 生成“无法获取源代码"pyinstaller 中的错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我从一个已经离开公司的人那里继承"了一个 python 应用程序,现在我很难让它在他自己的盒子里的晦涩设置之外工作.

I "inherited" a python app from a person who already left the company and now I'm having hard time getting it to work outside the obscure setup he had in his own box.

基本上我已经完成了一切以使其能够很好地编译并收集所有必要的模块,因此没有问题.它从 python 运行得很好.但是编译版本给了我这个:

Basically I have gone through everything to make it compile nicely and gathered all the necessary modules so there are no problems. It runs beautifully from python. However the compiled version gives me this:

LOADER: executable is C:\DSLR\v4\source\dist\SUAT\SUAT.exe
LOADER: homepath is C:\DSLR\v4\source\dist\SUAT
LOADER: _MEIPASS2 is NULL
LOADER: archivename is C:\DSLR\v4\source\dist\SUAT\SUAT.exe
LOADER: No need to extract files to run; setting extractionpath to homepath
LOADER: Already in the child - running user's code.
LOADER: manifestpath: C:\DSLR\v4\source\dist\SUAT\SUAT.exe.manifest
LOADER: Activation context created
LOADER: Activation context activated
LOADER: Python library: C:\DSLR\v4\source\dist\SUAT\python27.dll
LOADER: Manipulating evironment
LOADER: PYTHONPATH=C:\DSLR\v4\source\dist\SUAT
LOADER: PYTHONHOME=C:\DSLR\v4\source\dist\SUAT
LOADER: Manipulating Python's sys.path
LOADER: importing modules from CArchive
LOADER: extracted struct
LOADER: extracted pyi_os_path
LOADER: extracted pyi_archive
LOADER: extracted pyi_importers
LOADER: Installing import hooks
LOADER: out00-PYZ.pyz
LOADER: Running scripts
Filename is C:\DSLR\v4\source\dist\SUAT\enaml\core\parser.pyc
Sourcefile is C:\DSLR\v4\source\dist\SUAT\enaml\core\parser.py
ERROR:
Traceback (most recent call last):
  File "<string>", line 43, in <module>
  File "C:\DSLR\v4\source\build\SUAT\out00-PYZ.pyz\enaml", line 61, in imports
  File "c:\users\olli~1.man\appdata\local\temp\pip-build-9rafnl\pyinstaller\PyInstaller\loader\pyi_importers.py", line 2
70, in load_module
  File "C:\DSLR\v4\source\build\SUAT\out00-PYZ.pyz\enaml.core.import_hooks", line 18, in <module>
  File "c:\users\olli~1.man\appdata\local\temp\pip-build-9rafnl\pyinstaller\PyInstaller\loader\pyi_importers.py", line 2
70, in load_module
  File "C:\DSLR\v4\source\build\SUAT\out00-PYZ.pyz\enaml.core.parser", line 3931, in <module>
  File "C:\DSLR\v4\source\build\SUAT\out00-PYZ.pyz\ply.yacc", line 3273, in yacc
  File "C:\DSLR\v4\source\build\SUAT\out00-PYZ.pyz\ply.yacc", line 2931, in validate_all
  File "C:\DSLR\v4\source\build\SUAT\out00-PYZ.pyz\ply.yacc", line 2975, in validate_modules
  File "C:\DSLR\v4\source\build\SUAT\out00-PYZ.pyz\inspect", line 692, in getsourcelines
  File "C:\DSLR\v4\source\build\SUAT\out00-PYZ.pyz\inspect", line 540, in findsource
IOError: could not get source code
LOADER: RC: -1 from suat
LOADER: OK.
LOADER: Deactivating activation context
LOADER: Releasing activation context
LOADER: Done
LOADER: Cleaning up Python interpreter.

文件名和源文件是我添加到检查器模块的打印语句,以找出发生了什么.而且,是的,这些源文件确实不在那个 dist 文件夹中.令人讨厌的是,据我所知,SUAT.py 中绝对没有任何内容以任何方式寻址源或更改 os 目录.

Filename and sourcefile are print statements I added to the inspector module to figure out what's going on. And, yes, those sourcefiles indeed are not in that dist folder. What's nasty here is that as far as I can tell, there's absolutely nothing in the SUAT.py that addresses source in any way or changes the os directory.

遇到这种情况,我该怎么办?最近几天我一直在谷歌搜索直到我的眼睛流血了..我不知道为什么 ply.yacc 会去寻找源文件一个编译文件夹,因为源不应该在那里开始.FWIW,我使用的是最新的 PLY (3.6) 和 ENAML (0.9.8).无奈之下,我得到了 python(x y) 并安装了基本上所有的东西,但它没有改变任何事情.我已经安装了 mingw64,因为我之前遇到了api 版本已经设置为‘1’"的问题,并且需要运行 SIP 来更改运行时挂钩中的 api 文件.

How would I deal with something like this? I've been googling until my eyes bleed for the last few days.. I have no idea why ply.yacc would go looking for the source file a compiled folder as the sources are not expected to be there to start with. FWIW, I'm using latest PLY (3.6) and ENAML (0.9.8). In desperation I got python(x y) and installed basically everything but it didn't change a thing. I've installed mingw64 as I ran into the "api version already set to '1'" issue earlier and needed functioning SIP to change the api file in a runtime hook..

据我所知,所有路径都指向正确的位置,并且 pythonpath 设置正确.

As far as I can tell the paths are all pointing to correct places and pythonpath is set up as it should be.

C:\Python27\Scripts;C:\Python27;C:\Python27\opencv\build\x86\vc10\bin;C:\PYTHON27\opencv\build\python\2.7;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\Windows Live\Shared;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;c:\windows\system32\downlevel;C:\mingw-w64\i686-5.2.0-posix-dwarf-rt_v4-rev0\mingw32\bin

推荐答案

最后我编辑了 SPEC 文件,从 python site-packages 复制了相关的源文件.不太时尚,但它适用于单个文件夹构建.Enaml 绝对不应该在独立构建的 py 文件中进行拖钓.我只是不确定挖掘为什么这些特定的库作为 .py 文件而寻找的投资回报,而其余的被检查为 .pyd 是值得的.

In the end I ended up editing the SPEC file to copy the relevant source files from python site-packages. Not too stylish but it works for a single folder build. Enaml definitely should not go trolling for py-files in a stand-alone built. I'm just not sure the return of investment of digging out just why these particular libraries are sought as .py files while the rest is checked as .pyd is worth it.

这篇关于Python 2.7 ply.yacc 生成“无法获取源代码"pyinstaller 中的错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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