我有一个使用 SSL 的脚本,并使用 py2exe 构建(bundle_files=1,将所有内容打包到 *.exe 中)
在 Win7 上运行 py2exe 会创建一个 *.exe,它将在 Win7 和 Win10 中运行
在 Win10 上运行 py2exe 将创建一个 *.exe,它将在 Win10 中运行,但在 Win7 中会产生此错误:
ImportError: MemoryLoadLibrary failed loading _ssl.pyd
Run Code Online (Sandbox Code Playgroud)
将bundle_files设置为3(不打包)将生成一个*.exe,即使它是在Win10上构建的,它也可以在Win7中正常工作。
我尝试了一些 py2exe 选项,在更改 bundle_files 时突然它起作用了。但我不明白为什么。
两台机器上都一样(win7和win10)。
演示.py
import ssl
print "import done"
Run Code Online (Sandbox Code Playgroud)
可以使用这个exebuilder.py来构建它
from distutils.core import setup
import py2exe
import sys
sys.argv.append("py2exe") # run py2exe …Run Code Online (Sandbox Code Playgroud)