【问题标题】:pjsua: unable to import pjsua python modulepjsua:无法导入 pjsua python 模块
【发布时间】:2012-10-12 20:15:21
【问题描述】:

我在尝试导入 python 模块 pjsua 时遇到以下错误。我有 Mac OS 10.8.1 版本。我验证了http://www.darrensessions.com/?p=292 中提供的解决方案,该解决方案似乎已经在 MacOS-10.7 中解决了这个问题。对于 MacOS-10.8,这似乎又被打破了。编译代码时我没有遇到任何错误。仅在导入 PJSUA 模块时出现以下错误。

>>> import pjsua
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "pjsua.py", line 59, in <module>
    import _pjsua
ImportError: dlopen(/Library/Python/2.7/site-packages/_pjsua.so, 2): Symbol not found: _AudioOutputUnitStart
  Referenced from: /Library/Python/2.7/site-packages/_pjsua.so
  Expected in: flat namespace
 in /Library/Python/2.7/site-packages/_pjsua.so

非常感谢您的帮助。 谢谢,

【问题讨论】:

    标签: python sip osx-mountain-lion pjsip


    【解决方案1】:

    这个错误最近在 PJSIP 2.4 python 包中得到了修复:

    # OS X Lion (10.7.x) or above support
        if version[0] == '10' and int(version[1]) >= 7:
            extra_link_args += ["-framework", "AudioUnit"]
    

    有趣的是,我在同样的错误中运行:

        macbookproloreto:python admin$ python samples/simplecall.py 
    Traceback (most recent call last):
      File "samples/simplecall.py", line 23, in <module>
        import pjsua as pj
      File "/Library/Python/2.7/site-packages/pjsua.py", line 59, in <module>
        import _pjsua
    ImportError: dlopen(/Library/Python/2.7/site-packages/_pjsua.so, 2): Symbol not found: _pj_atexit
      Referenced from: /Library/Python/2.7/site-packages/_pjsua.so
      Expected in: flat namespace
     in /Library/Python/2.7/site-packages/_pjsua.so
    

    不明白为什么,因为检查平台版本的 Python setup.py 脚本似乎没问题:

    >>> import platform
    >>> version = platform.mac_ver()[0].split(".")
    >>> version
    ['10', '10', '4']
    >>> 
    

    【讨论】:

    • 确保您使用make &amp;&amp; make install。如果您忘记了 make 部分,则会出现该导入错误。
    【解决方案2】:

    一个直接的解决方案是(纯理论,尚未测试):

    1. http://lists.pjsip.org/pipermail/pjsip_lists.pjsip.org/2011-November/013722.html
    2. 看,补丁在哪里写:

      # OS X Lion Support
      if platform.mac_ver()[0].startswith("10.7"):
      extra_link_args += ["-framework", "AudioUnit"]
      
    3. 换行

      if platform.mac_ver()[0].startswith("10.7"):
      

      if platform.mac_ver()[0].startswith("10.7") or platform.mac_ver()[0].startswith("10.8"):
      
    4. 重新编译

    -- 编辑--

    好的,我按照我的建议对其进行了修补:

    > python ~/a.py 
    a
    > cat ~/a.py 
    import pjsua
    
    test = "a"
    print test
    

    【讨论】:

    • 您好,favoretti,我尝试了上述解决方案,但仍然出现错误。
    • 好的,让我试着为你打补丁。
    • 你做了make distcleanmake depmakemake install然后remake并重新安装python模块吗?
    • 一旦我按照您的建议删除并重新执行了该过程,从而解决了我的问题。谢谢!
    猜你喜欢
    • 2017-06-19
    • 2012-08-06
    • 1970-01-01
    • 1970-01-01
    • 2012-10-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多