2015-09-05 75 views
0

我使用OSX 10.9 + Kivy 1.9.1,但我有两个版本的Python,Mac OSX自包含2.7.5和另一个独立版本2.7.9安装。下面是详细信息:ImportError:Twisted需要zope.interface 3.6.0或更高版本:实际上已经安装

MacBook-Air:wzy$ python 

Python 2.7.5 (default, Mar 9 2014, 22:15:05) [GCC 4.2.1 Compatible Apple LLVM 5.0 (clang-500.0.68)] on darwin Type "help", "copyright", "credits" or "license" for more information.

MacBook-Air:wzy$ python 

Python 2.7.9 (v2.7.9:648dcafa7e5f, Dec 10 2014, 10:10:46) [GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin Type "help", "copyright", "credits" or "license" for more information.

具有pip install twisted装扭曲后,我得到了在kivy与Python 2.7.5,这并不在Python 2.7出现以下错误消息。 9

MacBook-Air:wzy$ kivy 
>>> import twisted 
Traceback (most recent call last): 
    File "<stdin>", line 1, in <module> 
    File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/twisted/__init__.py", line 53, in <module> 
    _checkRequirements() 
    File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/twisted/__init__.py", line 37, in _checkRequirements 
    raise ImportError(required + ": no module named zope.interface.") 
ImportError: Twisted requires zope.interface 3.6.0 or later: no module named zope.interface. 
MacBook-Air:wzy$ python 
>>> import twisted 
>>> exit() 

我甚至几次安装了zope.interface,并将安装目标目录专用为kivy环境的sys.path之一。

我确实相信这是两个版本共存的相关,但我该如何解决这个问题?

回答

2

当你做pip install twisted,要安装扭一些Python环境,这取决于python可执行你与调用pip。如果您有2.7.5环境和2.7.9环境,则pip install可能会针对每个环境在其他位置放置Twisted,具体取决于您传递给pip的其他选项。 (你可能通过一些其他选项pip install因为没有权限,默认情况下,pip install只会失败。你做sudo pip install吧?你这样做pip install作为管理员用户到家酿的Python?)

的正确方法要做到这一点,只能将Twisted安装到虚拟环境中。您可以使用-p选项创建一个虚拟环境,以virtualenv,该选项告诉它该环境使用哪个Python。然后,在正确的虚拟环境处于活动状态时,您可以使用pip install twisted,并且所有内容都应按照您的预期运行。

0

感谢雕文,

最后我发现下面简单的命令可以直接解决这个问题,因为Kivy用他自己的virtualenv环境,但我不明白你的好心帮。

kivy -m PIP安装扭曲

最好的祝福送给你,

0

我有同样的导入错误的问题,在这里提供了另一种可能的解决方案:

我有zope.interface 4.4。 2安装,事实证明,我的扭曲版本太旧了。通过升级扭曲解决了我的问题。 pip install --upgrade twisted

相关问题