加载pyinstaller时出错python27.dll错误 [英] Error loading python27.dll error for pyinstaller
问题描述
我已经成功编辑了规范文件,并将包含数据的文件夹添加到了该文件中.它构建良好,但仍然无法访问数据.当我尝试运行已编译的.exe时,出现以下错误:Error loading Python DLL: C:\Users\Sal\AppData\Local\Temp\_MEI60122\python27.dll (error code 126)
I have successfully edited my spec file and added the folder with my data to it. It builds fine but it still can't access the data. WHen i try to run the compiled .exe i get this error: Error loading Python DLL: C:\Users\Sal\AppData\Local\Temp\_MEI60122\python27.dll (error code 126)
编辑1-我仍然没有弄清楚我的规格文件看起来像这样:
EDIT 1 - I still don't have this figured out my spec file looks like this:
a = Analysis(['Clock_In.py'],
pathex=['C:\\Users\\Sal\\Desktop'],
hiddenimports=[],
hookspath=None,
runtime_hooks=None)
a.datas += [('CO_time.pkl','CO_time.pkl', 'DATA')]
a.datas += [('hours.pkl','hours.pkl', 'DATA')]
a.datas += [('Obj_file.pkl','Obj_file.pkl', 'DATA')]
a.datas += [('weekly_hours_dict.pkl','weekly_hours_dict.pkl', 'DATA')]
pyz = PYZ(a.pure)
exe = EXE(pyz,
a.datas,
a.binaries,
a.scripts,
exclude_binaries=True,
name='Clock_In.exe',
debug=False,
strip=None,
upx=True,
console=True,
icon="C:\Users\Sal\Desktop\Raindropmemory-Legendora-BrokenSword.ico")
coll = COLLECT(exe,
a.binaries,
a.zipfiles,
a.datas,
strip=None,
upx=True,
**name='Clock_In')
编辑2
我在64位操作系统(Windows 8)上使用32位python,已经引起我注意,这可能会引起我的问题,但仍然没有解决办法.
I am using 32-Bit python on a 64-bit OS(windows 8) and it has been brought to my attention that this could potentially be causing my issue, but still no solution.
编辑3
所以我刚刚尝试下载64位python并将其放在我的系统路径中.用我的.spec文件运行pyinstaller,仍然得到完全相同的错误代码!这里发生了什么!但是,一个令人好奇的细节是spec文件中的icon="C:\Users\Sal\Desktop\Raindropmemory-Legendora-BrokenSword.ico")
语句成功执行并更新了图标,而以前却没有.
So i have just tried download 64-bit python and putting it in my system path. ran pyinstaller with my .spec file and still got the exact same error code! What is going on here! A curious detail though is that the icon="C:\Users\Sal\Desktop\Raindropmemory-Legendora-BrokenSword.ico")
statement from spec file executed and updated the icon successfully, where as before it would not.
编辑4
这是我在MEIPASS代码中直接从文档中得到的声明.
This is the statement i have in my code for MEIPASS straight from the documentation.
if getattr(sys, 'frozen', False):
# we are running in a |PyInstaller| bundle
basedir = sys._MEIPASS
else:
# we are running in a normal Python environment
basedir = os.path.dirname(__file__)
推荐答案
您将该代码段放在要变成可执行文件的Python脚本的顶部,而不是放在规范中,也不在其自己的脚本中.我在这里找到了一个例子:
You put that code snippet right at the top of the Python script you are turning into an executable - not in the spec and not in its own script. I found an example here:
https://shanetully.com /2013/08/cross-platform-deployment-python-applications-with-pyinstaller/
这篇关于加载pyinstaller时出错python27.dll错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!