[Twisted-Python] Re: [Twisted-web] installed twisted. twisted.web missing?

Phil Christensen phil at bubblehouse.org
Mon Oct 29 11:24:41 EDT 2007

On Oct 29, 2007, at 11:01 AM, Phil Christensen wrote:

> I saw this pop up over on -web, but I'd like to ask about this...
> On Oct 29, 2007, at 3:49 AM, David Reid wrote:
>> On Oct 28, 2007, at 6:14 PM, aaron smith wrote:
>>> quick newb question. I installed twisted from source on mac os x  
>>> leopard. When I run:
>>> >>python
>>> >>import twisted
>>> >>from twisted.web import http
>>> I get an ImportError: ImportError: No module named web
>> Unfortunately there is an incomplete distribution of twisted 2.4  
>> in /System/Library/Frameworks
>> Your source install likely went into /Library/Python/2.5/site- 
>> packages/ which is also unfortunately  after /System/Library/ 
>> Frameworks in the PYTHONPATH.
>> Put /Library/Python/2.5/site-packages/ at the front of your  
> This seems like a relatively large issue with respect to Twisted  
> support on Mac OS X. Is it really going to be necessary to set an  
> environment variable anywhere you want to use Twisted? I guess this  
> would be an issue for any of the packages distributed in Extras, but  
> this is the one I have the most opinions about ;-)...
> Is there some other way to modify your path? I assume .pth files  
> won't work for this, since they only append to the path.

I'm going to answer my own question on this. A nice way to fix this is  
to create a .pth file in /Library/Python/2.5/site-packages, with the  
following line:

	import sys; sys.path.insert(0, '/Library/Python/2.5/site-packages')

On my machine for some reason i see the site-packages directory in  
there twice (even before this .pth file was added), so there's a part  
of me that wants to go with:

	import sys; sys.path = [s for s in sys.path if s != '/Library/Python/ 
2.5/site-packages']; sys.path.insert(0, '/Library/Python/2.5/site- 

but that only seems to get rid of one of them. It doesn't seem to  
matter anyways, so I guess the first version is good enough.


More information about the Twisted-Python mailing list