如何在 Windows 上导入 python26.zip
我需要部署 python26 的嵌入式版本。
我让它在 Windows 下工作,按照 http://www.portablepython.com/ 的设置。
然而,在阅读此内容之后我尝试将所有内容打包到一个 zip 文件中,而忽略了 python.exe、python26.dll。但是,如果未预安装 python,则该方法不起作用。
另外,我尝试使用 python -mcompileall . 预编译所有内容,但没有成功。
当以这种方式运行 python 时,这是错误:
“导入站点”失败;使用 -v 表示 回溯
这是回溯:
# installing zipimport hook
import zipimport # builtin
# installed zipimport hook
# zipimport: found 1283 names in D:\Bajados\Adobe\python26.zip
'import site' failed; traceback:
ImportError: No module named site
我想知道可以使这项工作成功的内部细节。
I need to deploy a embeded version of python26.
I have it working under windows folowing the setup of http://www.portablepython.com/.
However after read this I try to pack everything into a zip file, and left out python.exe, python26.dll. However, that not work if python is not pre-installed.
Also, I try pre-compilling everything with python -m compileall .
, but not do the trick.
When run python this way, this is the error:
'import site' failed; use -v for
traceback
This is the traceback:
# installing zipimport hook
import zipimport # builtin
# installed zipimport hook
# zipimport: found 1283 names in D:\Bajados\Adobe\python26.zip
'import site' failed; traceback:
ImportError: No module named site
I want to know the inner details that could make this work.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
Py2EXE 会为你做这件事,它非常适合
distutils
,所以有几个在setup.py
中声明十几行,您将获得一个漂亮的 Windows 应用程序包,而无需任何 Python 依赖项。此外,您还可以与 Innosetup 进一步集成,它为您提供了一个很棒的单文件安装程序包。Py2EXE will do this for you, it fits nicely with
distutils
, so with a couple dozen lines of declaration insetup.py
you'll get a nice windows application package without any python dependencies. Also, you can integrate further with Innosetup which gives you a great single-file-installer package.也许查看标志 Py_NoSiteFlag = 1;
Perhaps look into the flag Py_NoSiteFlag = 1;