简体   繁体   English

Python 2.7 ply.yacc在pyinstaller中生成“无法获取源”错误

[英]Python 2.7 ply.yacc generates “cannot get source” error in pyinstaller

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. 它从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.

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. 而且,是的,这些源文件确实不在该dist文件夹中。 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. 令人讨厌的是,据我所知,SUAT.py中绝对没有任何内容可以以任何方式寻址源代码或更改os目录。

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. 我一直在谷歌搜索,直到最后几天我的眼睛流血。.我不知道为什么ply.yacc会去寻找已编译文件夹的源文件,因为不希望源头开始。 FWIW, I'm using latest PLY (3.6) and ENAML (0.9.8). FWIW,我正在使用最新的PLY(3.6)和ENAML(0.9.8)。 In desperation I got python(xy) and installed basically everything but it didn't change a thing. 无奈之下,我得到了python(xy)并基本上安装了所有东西,但并没有改变任何东西。 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.. 我已经安装了mingw64,因为我之前遇到了“ api版本已经设置为'1'”的问题,并且需要运行SIP才能在运行时挂钩中更改api文件。

As far as I can tell the paths are all pointing to correct places and pythonpath is set up as it should be. 据我所知,所有路径均指向正确的位置,并且pythonpath已设置为正确的位置。

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

In the end I ended up editing the SPEC file to copy the relevant source files from python site-packages. 最后,我结束了对SPEC文件的编辑,以从python站点包中复制相关的源文件。 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. 对于独立构建的py文件,Enaml绝对不应拖延。 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. 我只是不确定为什么要寻找这些特定的库作为.py文件,而将其余的作为.pyd进行检查是否值得的投资回报。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM