在OS X Mavericks上使用twisted

3

我正在尝试在OS X Mavericks上使用twisted,但是当我尝试导入它时,我遇到了这个错误消息。

christohersmbp2:~ christopherspears$ python
    Python 2.7.6 (default, Mar  8 2014, 09:29:01) 
    [GCC 4.2.1 Compatible Apple LLVM 5.0 (clang-500.2.79)] on darwin
    Type "help", "copyright", "credits" or "license" for more information.
    >>> import twisted
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
    ImportError: No module named twisted

我的猜测是我收到这个错误是因为我没有使用默认的Python。我正在使用通过brew安装的Python。理想情况下,我想要在虚拟环境中安装twisted来进行测试,但是文档缺乏细节。显然,在Mac OS X 10.5上存在一个dmg文件,但对我没有帮助。我可以从tarball中安装到虚拟环境中,但我不确定如何操作。有什么提示吗?


你安装了Twisted吗? - user1971598
1个回答

13
如果您正在使用virtualenv,那么使用系统Python与否并不重要。
只需在您的虚拟环境中执行pip install twisted即可,例如:
$ workon MyTwistedEnv
$ pip install twisted

目前,由于Xcode中存在一个影响所有包含扩展模块的项目的错误, 您可能需要拼写这个单词

$ CFLAGS= pip install twisted

希望这个问题能够尽快得到解决。不过这可能不会影响使用brew安装的Python。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接