【问题标题】:How does Python import modules from .egg files?Python 如何从 .egg 文件中导入模块?
【发布时间】:2010-10-25 11:37:30
【问题描述】:

如何在此处打开__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 文件,但是包的内部文件在哪里?

【问题讨论】:

    标签: python module packages


    【解决方案1】:

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

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

    用你的 zip 程序打开 egg,或者只是将扩展名重命名为 .zip,然后解压。

    【讨论】:

    • 太棒了!我不知道。
    【解决方案2】:

    例如,如果您要导入以 .egg 文件形式提供的 suds 模块:

    在你的 python 脚本中:

    egg_path='/home/shahid/suds_2.4.egg'
    
    sys.path.append(egg_path)
    
    import suds
    #... rest of code
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-11-22
      • 1970-01-01
      • 1970-01-01
      • 2011-08-17
      • 2015-06-27
      • 2013-08-26
      • 2018-06-01
      • 2020-02-04
      相关资源
      最近更新 更多