【发布时间】:2016-05-17 10:25:10
【问题描述】:
简介
我有一个使用 SSL 并使用 py2exe 构建的脚本(bundle_files=1,将所有内容打包到 *.exe 中)
现在我遇到了这个问题
在 Win7 上运行 py2exe 会创建一个 *.exe,它将在 Win7 和 Win10 中运行
在 Win10 上运行 py2exe 会创建一个 *.exe,它将在 Win10 中运行,但在 Win7 中会产生此错误:
ImportError: MemoryLoadLibrary failed loading _ssl.pyd
解决方法
将 bundle_files 设置为 3(不要打包)将导致 *.exe 在 Win7 中运行良好,即使它是在 Win10 上构建的。
我尝试了一些 py2exe 选项,但在更改 bundle_files 时它突然起作用了。 但我不明白为什么。
我的设置
- python 32bit 2.7.11
- ssl.OPENSSL_VERSION => 'OpenSSL 1.0.2d 2015 年 7 月 9 日'
- py2exe 0.6.9
在两台机器上都一样(win7 和 win10)。
这是一个重现它的最小演示:
demo.py
import ssl
print "import done"
可以用这个来构建
exebuilder.py
from distutils.core import setup
import py2exe
import sys
sys.argv.append("py2exe") # run py2exe (instead of supplying the command line argument)
# exclude some DLLs
dll_excludes = [
# win9x leftovers
"w9xpopen.exe",
# don't import these - otherwise win7 created *.exe won't work in winXP
# http://stackoverflow.com/questions/1979486/py2exe-win32api-pyc-importerror-dll-load-failed
"mswsock.dll",
"powrprof.dll"
]
sys.argv.append("--dll-excludes=%s" % ",".join(dll_excludes))
app_name = "win10ssl"
params = {
'zipfile': None, # pack everything into the *.exe
'options': {
"py2exe": {
"compressed": 1,
"optimize": 2,
# bundle_files
# 1 = EVERYTHING packed into the *.exe
# 2 = everything except for the pythonXX.dll
# 3 = don't pack
"bundle_files": 3
}
},
'version': "0.0.1.0",
'description': "demo to show MemoryLoadLibrary error",
'name': app_name,
'console': [{
"script": "demo.py",
"dest_base": app_name
}
]
}
setup(**params)
【问题讨论】:
标签: python python-2.7 ssl py2exe