Domanda

I am trying to use twisted on OS X Mavericks, but I get this error message when I try to import it.

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

My guess is that I am receiving this error because I am not using the default Python. I am using a Python installed with brew. Ideally, I would want to install twisted into a virtual environment to play with, but the docs are seriously lacking in details. Apparently, a dmg exists for Mac OS X 10.5, which is not helpful for me. I can install from the tarball into the virtual environment, but I am not sure how to do this. Any hints?

È stato utile?

Soluzione

If you're using virtualenv, it doesn't matter whether you are using the system python or not.

Simply pip install twisted in your virtualenv, like:

$ workon MyTwistedEnv
$ pip install twisted

Currently, due to a bug in Xcode that affects all projects which contain extension modules, you may need to spell this

$ CFLAGS= pip install twisted

instead; hopefully this will be fixed soon. It may not affect brew installed Pythons, however.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top