Skip to main content
 首页 » 编程设计

python之在 Mac OS/X 1.8.5 中为 Python 2.7 安装 Twisted

2025年05月04日10arxive

一些版本,首先:

mac osx 版本:

$ system_profiler SPSoftwareDataType 
Software: 
 
    System Software Overview: 
 
      System Version: OS X 10.8.5 (12F45) 
      Kernel Version: Darwin 12.5.0 
      Boot Volume: Macintosh HD 
      Boot Mode: Normal 

python :

$ python 
Python 2.7.2 (default, Oct 11 2012, 20:14:37) 
[GCC 4.2.1 Compatible Apple Clang 4.0 (tags/Apple/clang-418.0.60)] on darwin 

zope:

>>> import zope 
>>> zope.__path__ 
['/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/zope', '/Library/Python/2.7/site-packages/zope.interface-4.1.1-py2.7-macosx-10.8-intel.egg/zope'] 

所以.. Max 1.8.5 与 python 2.7 和 zope 4.1

那么..问题:

>>> import twisted 
    Traceback (most recent call last): 
  File "<stdin>", line 1, in <module> 
  File "/Library/Python/2.7/site-packages/twisted/__init__.py", line 53, in <module> 
    _checkRequirements() 
  File "/Library/Python/2.7/site-packages/twisted/__init__.py", line 51, in _checkRequirements 
    raise ImportError(required + ".") 
ImportError: Twisted requires zope.interface 3.6.0 or later. 

可以肯定的是,我在 sudo 执行 python setup.py install、easy_install、pip 和其他命令时搞砸了一些事情,但是……问题是:

如何安装更新版本的 twisted?

请您参考如下方法:

OS X 10.8 附带 Zope Interface 3.5.1。但是,当您将 Twisted 安装到 /Library 时,您并没有同时安装更新的可导入版本的 Zope Interface。

删除您安装的 Twisted 版本。 OS X 10.8 已经附带了 Twisted 12.0,这对于您正在做的事情来说可能已经足够好了。如果您需要更新的版本,请将其安装到 virtualenv 中并在那里使用它。 https://pip2014.com/可以让您开始使用必要的工具来执行此操作, sudo ;-)

不会搞砸您的系统