Python如何从.egg文件导入模块?

2024-06-28 10:07:13 发布

您现在位置:Python中文网/ 问答频道 /正文

如何在此处打开__init__.pyc

    >>> import stompservice
    <module 'stompservice' from 'C:\Python25\lib\site-packages\stompservice-0.1.0-py2.5.egg\stompservice\__init__.pyc'>

我在C:\Python25\lib\site-packages\中看到的只是.egg文件,但是包的内部文件在哪里?


Tags: 文件fromimportinitegglibpackagesservice
2条回答

http://peak.telecommunity.com/DevCenter/PythonEggs

.egg文件只是重命名为zip文件。

使用zip程序打开egg,或者将扩展名重命名为.zip,然后解压缩。

例如,如果要导入可作为.egg文件使用的suds模块:

在python脚本中:

egg_path='/home/shahid/suds_2.4.egg'

sys.path.append(egg_path)

import suds
#... rest of code

相关问题 更多 >