python 如何解压蟒蛇蛋?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2019565/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-11-03 23:35:00  来源:igfitidea点击:

How to unzip python eggs?

pythonpy2exeeasy-installegg

提问by Fluffy

I'm trying to bundle some egg dependencies when using py2exe and as stated on the py2exe site, it doesn't work with those and I need to unzip them first. I've tried to first run easy_install -m lxmland then easy_install --always-unzip lxml==2.2.2, but it didn't work. Then I tried to set the unzipping behaviour to default by putting it to distutils.cfg. I didn't find the latter file, so I've made the HOMEenvironment variable and created a pydistutils.cfgfile there with this content:

我正在尝试在使用 py2exe 时捆绑一些 egg 依赖项,正如 py2exe 站点上所述,它不适用于那些,我需要先解压缩它们。我试过先运行easy_install -m lxml,然后运行easy_install --always-unzip lxml==2.2.2,但没有奏效。然后我尝试将解压缩行为设置为默认值distutils.cfg。我没有找到后一个文件,所以我HOME创建了环境变量并在pydistutils.cfg那里创建了一个包含以下内容的文件:

[easy_install]
zip_ok = 0

but easy_install still doesn't unpack the eggs. What is the easiest way to get things done?

但是 easy_install 仍然没有打开鸡蛋。完成任务的最简单方法是什么?

采纳答案by Ryan Ginstrom

Quick hack/workaround: egg files are just zip files, so you can use the python zipfile module to unzip them. Maybe you could rename the easy_install file to "easy_install_pre.exe", and create a new .bat file named "easy_install.bat":

快速破解/解决方法:egg 文件只是 zip 文件,因此您可以使用 python zipfile 模块来解压缩它们。也许您可以将 easy_install 文件重命名为“easy_install_pre.exe”,并创建一个名为“easy_install.bat”的新 .bat 文件:

easy_install_pre.exe %1
unzip_eggs.py %1

回答by hynekcer

The zippped package file should be first removed before reinstalling. Then is is easy.

在重新安装之前,首先删除压缩包文件。然后很容易。

All methods of unzipped installation described in the question should work if the zipped package is removed first but does not work without it. Reinstallation of zipped package after unzipped installation is on the contrary possible by normal upgrade without need to remove anything. This was typical for some old easy_install versions related appoximately to period of Python 2.5.

如果首先删除压缩包,但如果没有它,则问题中描述的所有解压缩安装方法都应该有效。相反,在解压安装后重新安装压缩包可以通过正常升级而无需删除任何内容。这对于一些与 Python 2.5 时期相关的旧 easy_install 版本来说是典型的。