Fucking Python! (5)

1 Name: Albright!LC/IWhc3yc 2004-11-27 01:49 ID:M0mxtIwg [Del]

Could someone explain this lovely little behavior of Python to me? When running Python interactively, I'll be able to import any given module;

>>> import xml.parsers.expat
>>> import wxPython.wx
>>>

Then, when I try to run a script with these import commands, Python can't find those modules. So I go back to the interactive session with Python, and suddenly I can't import the same modules there either.

>>> import xml.parsers.expat
Traceback (most recent call last):
File "<stdin>", line 1, in ?
File "/Users/Albright/xml.py", line 3, in ?
import xml.parsers.expat
ImportError: No module named parsers.expat
>>> import wxPython.wx
Traceback (most recent call last):
File "<stdin>", line 1, in ?
File "//Library/Python/2.3/wx-2.5.3-mac-unicode/wxPython/__init__.py", line 10, in ?
import _wx
File "//Library/Python/2.3/wx-2.5.3-mac-unicode/wxPython/_wx.py", line 3, in ?
from _core import *
File "//Library/Python/2.3/wx-2.5.3-mac-unicode/wxPython/_core.py", line 15, in ?
import wx._core
File "/Users/Albright/wx.py", line 2, in ?
from wxPython.wx import *
ImportError: No module named wx
>>>

Nothing I've found will let me get those modules back. What's the deal? :(

2 Name: Albright!LC/IWhc3yc 2004-11-27 04:19 ID:M0mxtIwg [Del]

Found a bit of a workaround... If I copy that xml.parsers.expat module from the directory where modules are stored into the same directory the script is stored or I run the Python CLI from, I can import it. I shouldn't have to do this, though, and I haven't found out how to replicate this workaround with wxPython, which I'd also like to use.

Fucking Python. I wish I could do GUI programs with PHP. For as long as Python has been around, it seems really immature at times...

/me investigates Ruby

3 Name: dmpk2k!hinhT6kz2E 2004-11-27 08:52 ID:Nc4GwN+A [Del]

So many languages, so little time...

4 Name: Albright!LC/IWhc3yc 2004-11-27 11:04 ID:M0mxtIwg [Del]

Have I mentioned I'm a dumbass recently?

The reasons both of these were failing is because my test scripts were named xml.py and wx.py, and they were both in ~, where I was running Python from more often than not. So Python was trying to import those instead of the correct modules. It was behaving correctly. (I was to the point where I was machine-translating messages from the Chinese Python mailing list before this occurred to me.)

So it turned out to be a ID-10-T error the whole time. Sorry for starting a thread about this.... Gyaah.

5 Name: Anonymous 2004-11-27 13:45 ID:Heaven [Del]

>>4

It's better than this place being a dead shithole...

This thread has been closed. You cannot post in this thread any longer.