Python: CFURLCreateWithString was passed this invalid URL string: '/System/Library/CoreServices/CommonCocoaPanels.bundle' (a file system path instead of an URL string). The URL created will not work with most file URL function

I have a wxPython program (the same one I’ve been working on for a while) and it consists of two classes in one file, say “1.py”. At the bottom, I call:

if name == ‘main’:
app = MainApp(False)

#import wx.lib.inspection

#wx.lib.inspection.InspectionTool().Show()

app.MainLoop()

which works fine, though it throws the error in the subject line.

If I create a main.py file, import 1.py, and then do:

1.MainApp()

which is the name of the main class, it throws the error in the subject line and I don’t get the program.

What am I doing wrong? I assume the error in the subject line can’t be the issue because the program works fine if I call it directly instead of importing and calling.

Thanks in advance, especially as I’m sure this is going to be something fairly obvious I’m missing.

I see that error all the time on Mac OS X (although always only once
per run of a program). I don't think it has anything to do with
whether your program runs correctly or not.

Cheers, Frank

···

2012/3/24 tdahsu <tdahsu@gmail.com>:

which works fine, though it throws the error in the subject line.

tdahsu wrote:

I have a wxPython program (the same one I've been working on for a
while) and it consists of two classes in one file, say "1.py". At the
bottom, I call:

if __name__ == '__main__':
    app = MainApp(False)
# #import wx.lib.inspection
# #wx.lib.inspection.InspectionTool().Show()
    app.MainLoop()

which works fine, though it throws the error in the subject line.

If I create a main.py file, import 1.py, and then do:

How did you do that, exactly?

C:\tmp>type x.py
import 1
print "zero"
print 1.two()

C:\tmp>python x.py
  File "x.py", line 1
    import 1
           ^
SyntaxError: invalid syntax
C:\tmp>

1.MainApp()

which is the name of the main class, it throws the error in the
subject line and I don't get the program.

What am I doing wrong?

I would have hoped that the problem here was obvious. The Python
parser ALWAYS recognizes the text "1" as an integer. If it didn't, your
program could never use the number 1 as a constant. There are languages
that do that, but not Python.

Rule: always start your module names with a letter.

···

--
Tim Roberts, timr@probo.com
Providenza & Boekelheide, Inc.