Mailing List Archive

'import exceptions' failed
I have compiled the python source into a Windows DLL and using
this DLL I have embedd python into and windows text editor. Now
when I run the following macro script:

import editor_functions

def key_macro():
print "this is a macro.";

key_macro() # run the macro

the macro runs fine and produces the expected ouput in the
text editor, but I also get the following messages sent to
stderr:

'import exceptions' failed; use -v for traceback
defaulting to old style exceptions
'import site' failed; use -v for traceback

To run the macro it is saved to file and is run using the
python API:

PyRun_SimpleFile

My question is have I missed something? What setup changes do I
need to do to remove this error or how do I simulate -v using
the Python API C functions so that this error is not generated?

Thanks in advance.

Cheers Jussi Jumppanen
'import exceptions' failed [ In reply to ]
Jussi Jumppanen:
|I have compiled the python source into a Windows DLL and using
...
|the macro runs fine and produces the expected ouput in the
|text editor, but I also get the following messages sent to
|stderr:
|
| 'import exceptions' failed; use -v for traceback
| defaulting to old style exceptions
| 'import site' failed; use -v for traceback

I don't know if your case is the same, but when I saw this, I discovered
that if $PYTHONPATH (normally used to augment Python's run-time module
search path) is defined when Python is built. This completely overrides
the default Python search path which it uses to find its own modules.

As I recall, "import exceptions" was the first thing it complained about.
I think site was the second but I'm not certain.

Randall
'import exceptions' failed [ In reply to ]
You are obviously investing serious time with Python, so you should try and
go to the next level. Compile the whole shabang with Debugging symbols, and
work it out :-) The biggest advantage is that it will give you a good
understanding of the internals, making many of these questions suddenly
become either obvious or moot.

For example, you ask how to turn "-v" on from the API - simple - go to the
Python sources, work out how it does -v, then do the same thing! Should be
easy to find.

Similarly with the path issue. Set a breakpoint where Python is about to
start building your sys.path. Step through it, and understand exactly why
it is building a sys.path that does not include the directory where your
"exceptions.py" and "site.py" live. The answer will then be obvious (even
though I have no idea what it is :-)

Hope this helps, even if it points to a slightly longer, but far more
beneficial road.

Mark.
BTW - what editor control are you using? - I happen to know this guy who has
written a really cool free one that Pythonwin now uses - Ive got some big
plans :-)

Jussi Jumppanen wrote in message <371B1201.392B@iname.com>...
>I have compiled the python source into a Windows DLL and using
>this DLL I have embedd python into and windows text editor. Now
>when I run the following macro script: