Search code examples
pythonosx-snow-leopardtwistedbash

Python 2.7.1 can't see Twisted


I have a new MacBook Pro running OS X 10.6.6 / Snow Leopard -- which ships with Python 2.6, although I have installed 2.7.1

Unfortunately, this doesn't seem to see the Twisted install in the 2.6/Extras/lib/python/twisted directory, as I find I'm unable to import modules that I can see are present in that directory.

"which python" returns "/Library/Frameworks/Python.framework/Versions/2.7/bin/python"

and running python returns the same: "Python 2.7.1 (r271:86882M, Nov 30 2010, 10:35:34)"

I have added the twisted directory (absolute) to sys.path, and I have added it to .bash_profile, which now consists of the following:

PATH="/Library/Frameworks/Python.framework/Versions/2.7/bin:${PATH}" PATH=$PATH:/System/Library/Frameworks/Python.framework/Versions/2.6/Extras/lib/python/twisted export PATH

Any ideas how I can get 2.7.1 to see the Twisted install? Or am I trying to do something that just can't be done?

thanks.


Solution

  • You'll need to install Twisted into your Python 2.7 installation somehow. The "2.6" in that path should be a hint that you shouldn't be trying to tell Python 2.7 about it. Among other things:

    • Extension modules are not compatible between python versions. You may get a segfault if you try to use them.
    • Bytecode formats are not compatible between python versions. Python will fall back to parsing '.py' files, which is slower.
    • If you're using an operating system that ships with Python 2.6, there is a good chance that the version of Twisted included is not compatible with Python 2.7, since Python 2.7 may not have been out yet when it was released.