[wingide-users] MacOSX 10.4: Twisted in WingIDE

Wingware Support support at wingware.com
Mon Sep 24 08:24:17 MDT 2007


It could be a bug, tho a strange one.  It would expect it to fail in
the shell rather than debugger, if anything.

What is the os.getcwd() in each case (the shell and debugger)?  Also,
what happens if you add something like this before the import:

import sys
sys.path.append('')

and maybe also:

import os
os.chdir(x)

where x is the value of os.getcwd() in the shell case.

The only other thing that may be worth looking at is the How-To
for Twisted in Wing 3.0's Help menu.  It may be calling run()
in the way described there has some effect on the path, although
again this doesn't really explain why it works in the shell
and I'd have expected that to not work if it's anything other
than just having '' on the path and correct working dir.

Please let us know if this helps or not.  If not, I'll try
to replicate it here.

Thanks,

- Stephan


Scott Syms wrote:
> Hi, no joy-
> 
> I've tried this under 3.x now.
> 
> I can run the line
> 
> from twisted.internet.protocol import Factory, Protocol
> 
> from python started from a terminal and the Wing Python shell.  If I 
> include this line in a script, I get an ImportError complaining that 
> there's no module called internet.protocol
> 
> PYTHONPATH-
> 
> As for pythonpath, in my python shell in wing i have:
> ['',
>  '/Applications/WingIDE.app/Contents/MacOS/src/debug/tserver',
>  '/System/Library/Frameworks/Python.framework/Versions/2.3/lib/python23.zip', 
> 
>  '/System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3',
>  '/System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/plat-darwin', 
> 
>  '/System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/plat-mac', 
> 
>  '/System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/plat-mac/lib-scriptpackages', 
> 
>  '/System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/lib-tk', 
> 
>  '/System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/lib-dynload', 
> 
>  '/System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/site-packages', 
> 
>  '/System/Library/Frameworks/Python.framework/Versions/2.3/Extras/lib/python', 
> 
>  '/System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/site-packages'] 
> 
> 
> Echoed from my script I've got:
> 
> ['/Users/scottsyms/development/scratch',
>  '/System/Library/Frameworks/Python.framework/Versions/2.3/lib/python23.zip', 
> 
>  '/System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3',
>  '/System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/plat-darwin', 
> 
>  '/System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/plat-mac', 
> 
>  '/System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/plat-mac/lib-scriptpackages', 
> 
>  '/System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/lib-tk', 
> 
>  '/System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/lib-dynload', 
> 
>  '/System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/site-packages', 
> 
>  '/System/Library/Frameworks/Python.framework/Versions/2.3/Extras/lib/python', 
> 
>  '/System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/site-packages'] 
> 
> 
> I'm thinking this is a bug. Anything to suggest?
> 
> tks
> 
> S
> 
> 
> On 20-Sep-07, at 11:44 PM, Wingware Support wrote:
> 
>> Scott Syms wrote:
>>> I've installed twisted in the Mac's default python installation.  I 
>>> can import twisted modules in the python interpreter and the WingIDE 
>>> supplied python shell when I explicitly provided the python binary 
>>> and module paths in the projects definition.
>>> However, when I write a twisted import statement in the script 
>>> window, it fails when I try to debug code- error is:
>>> ImportError: No module named internet.protocol
>>> Traceback (innermost last):
>>> File "/Users/path/development/scratch/twisted.py", line 1, in ?
>>>   #!/bin/env python
>>> File "/Users/path/development/scratch/twisted.py", line 2, in ?
>>>   from twisted.internet.protocol import Protocol, Factory
>>> File "/Users/path/development/scratch/twisted.py", line 2, in ?
>>>   from twisted.internet.protocol import Protocol, Factory
>>> The import lines are: from twisted.internet.protocol import Protocol, 
>>> Factory
>>> from twisted.internet import reactor
>>> This should work, but why am I getting different results from the 
>>> WingIDE shell and the debug interpreter?  Any workaround?
>>
>> Are you starting the debug process from outside Wing?  The Python
>> Shell in Wing and the debug process if launched from Wing should
>> have identical environment (in fact the shell in Wing is implemented
>> using the debugger).
>>
>> If launching from within Wing it would be work checking what
>> sys.path are in each case.
>>
>> Oh, perhaps this is working in the shell because os.getcwd()
>> differs and you have '.' or a partial path on your sys.path?
>>
>> You seem to be using Wing 2.1 but I'll just note that in
>> Wing 3.0 we add '.' to the sys.path when running in the
>> Python Shell but not in the debug process.  This would be
>> a possible explanation of the problem there.
>>
>> Please let us know if none of this helps.
>>
>> Thanks,
>>
>> -- 
>>
>> Stephan Deibel
>> Wingware | Python IDE
>> Advancing Software Development
>>
>> www.wingware.com
>>


-- 

Stephan Deibel
Wingware | Python IDE
Advancing Software Development

www.wingware.com



More information about the wingide-users mailing list