newbie - script works in PythonWin - fails from Python

Discussion in 'Python' started by marcus.tettmar@gmail.com, Feb 3, 2006.

  1. Guest

    Hi,

    I have a script that runs fine when I run it from within PythonWin but
    causes a WindowsError: Exception when I try to run it from the command
    line using python.exe. What is PythonWin doing differently?
     
    , Feb 3, 2006
    #1
    1. Advertising

  2. wrote:

    > I have a script that runs fine when I run it from within PythonWin but
    > causes a WindowsError: Exception when I try to run it from the command
    > line using python.exe. What is PythonWin doing differently?


    is that the entire traceback ?

    what is the script doing when you get that error message ?

    </F>
     
    Fredrik Lundh, Feb 3, 2006
    #2
    1. Advertising

  3. Fuzzyman Guest

    wrote:
    > Hi,
    >
    > I have a script that runs fine when I run it from within PythonWin but
    > causes a WindowsError: Exception when I try to run it from the command
    > line using python.exe. What is PythonWin doing differently?


    Hello Marcus,

    Can you post the full exception, and preferably the snippet of code
    (with relevant context) that caused it. This will give people a better
    chance of being able to help you.

    All the best,


    Fuzzyman
    http://www.voidspace.org.uk/python/index.shtml
     
    Fuzzyman, Feb 3, 2006
    #3
  4. Guest

    I'm using ctypes and loading a DLL and running a DLL function. As I
    say it works perfectly with no errors when I run from PythonWin but
    gives the following exception when run from command line.

    WindowsError: exception code 0xeedfade

    I can use the DLL with no issues in other languages too. It works fine
    in VB, C++ and in Python when run from PythonWin but gets an exception
    when run from python.exe

    PythonWin must be doing something different, but I can't find anything
    in the documentation.
     
    , Feb 3, 2006
    #4
  5. On Fri, 03 Feb 2006 02:29:03 -0800, marcus.tettmar wrote:

    > I'm using ctypes and loading a DLL and running a DLL function. As I
    > say it works perfectly with no errors when I run from PythonWin but
    > gives the following exception when run from command line.
    >
    > WindowsError: exception code 0xeedfade


    I find it hard to believe that this is the entire exception traceback.
    This is what a traceback looks like:


    >>> dosomething wrong(20) # oops, space in the function name

    File "<stdin>", line 1
    dosomething wrong(20)
    ^
    SyntaxError: invalid syntax

    See how much information is given by the traceback? If I just posted
    "SyntaxError: invalid syntax" to the newsgroup with no further
    information, what do you think the chances are anyone would guess the
    cause of the problem?

    So, how about trying again with the complete traceback?


    --
    Steven.
     
    Steven D'Aprano, Feb 3, 2006
    #5
  6. Guest

    Hi,

    This is all I get:

    error 250477278
    Traceback (most recent call last):
    File "script1.py", line 5, in ?
    Inst = lib.Initialize(0)
    WindowsError: exception code 0xeedfade

    I get this when running python.exe script1.py

    ** When run from inside PythonWin it runs beautifully and returns with
    no errors **

    Regardless of what the error actually is it *works* when run from
    PythonWin. It fails only when run from the command line. I'm trying
    to find out why there is a difference. Clearly both either run a
    different interpreter or with different switches. I was hoping someone
    knows what the difference is.
     
    , Feb 3, 2006
    #6
  7. writes:

    > Hi,
    >
    > This is all I get:
    >
    > error 250477278
    > Traceback (most recent call last):
    > File "script1.py", line 5, in ?
    > Inst = lib.Initialize(0)
    > WindowsError: exception code 0xeedfade
    >
    > I get this when running python.exe script1.py
    >
    > ** When run from inside PythonWin it runs beautifully and returns with
    > no errors **
    >
    > Regardless of what the error actually is it *works* when run from
    > PythonWin. It fails only when run from the command line. I'm trying
    > to find out why there is a difference. Clearly both either run a
    > different interpreter or with different switches. I was hoping someone
    > knows what the difference is.


    One difference is that PythonWin runs a messageloop. Does the
    documentation of the library you call say something about the error code
    you get?

    Thomas
     
    Thomas Heller, Feb 3, 2006
    #7
  8. Guest

    Unfortunately not. Is there any doc anywhere that shows how to make
    the script run from the command line the same way it does within
    PythonWin?
     
    , Feb 3, 2006
    #8
  9. On Fri, 03 Feb 2006 07:00:37 -0800, marcus.tettmar wrote:

    > Hi,
    >
    > This is all I get:
    >
    > error 250477278


    What is this line? That doesn't look like part of a Python traceback. I
    suppose it is possible that the DLL is printing it before the exception is
    raised. Or did you type it yourself?


    > Traceback (most recent call last):
    > File "script1.py", line 5, in ?
    > Inst = lib.Initialize(0)
    > WindowsError: exception code 0xeedfade
    >
    > I get this when running python.exe script1.py


    You're still making it as hard as possible for anyone to help you. Is it a
    secret what DLL you are trying to call? What is "lib"?

    Googling on 0xeedfade suggests that it is an internal Delphi error,
    possibly an out-of-memory error. Are you calling a Delphi DLL? What does
    that exception mean?


    --
    Steven.
     
    Steven D'Aprano, Feb 3, 2006
    #9
  10. Thomas Heller wrote:

    > > This is all I get:
    > >
    > > error 250477278
    > > Traceback (most recent call last):
    > > File "script1.py", line 5, in ?
    > > Inst = lib.Initialize(0)
    > > WindowsError: exception code 0xeedfade
    > >
    > > I get this when running python.exe script1.py
    > >
    > > ** When run from inside PythonWin it runs beautifully and returns with
    > > no errors **
    > >
    > > Regardless of what the error actually is it *works* when run from
    > > PythonWin. It fails only when run from the command line. I'm trying
    > > to find out why there is a difference. Clearly both either run a
    > > different interpreter or with different switches. I was hoping someone
    > > knows what the difference is.

    >
    > One difference is that PythonWin runs a messageloop. Does the
    > documentation of the library you call say something about the error code
    > you get?


    a quick googling indicates that 0xEEDFADE is usually caused by an
    internal unhandled exception in Delphi. maybe there's some Borland-
    specific DLL that's not found when the code is running from the con-
    sole ?

    I suppose you could use process explorer to see if you can figure out
    what Borland DLL:s the program is using:

    http://www.sysinternals.com/ProcessesAndThreadsUtilities.html

    </F>
     
    Fredrik Lundh, Feb 3, 2006
    #10
  11. Guest

    Hi,

    Sorry, I'm not trying to make things hard! I just can't figure why it
    works when run from PythonWin and not from Python - PythonWin MUST load
    some extra library.

    Anyway, I have finally fixed it by adding import win32com to the top of
    the script. Am guessing the DLL uses COM and PythonWin must already
    load it.
     
    , Feb 3, 2006
    #11
  12. On 3 Feb 2006 09:18:57 -0800, declaimed the
    following in comp.lang.python:


    > Anyway, I have finally fixed it by adding import win32com to the top of
    > the script. Am guessing the DLL uses COM and PythonWin must already
    > load it.


    <duh> From the help system:

    -=-=-=-=-=-=-=-
    On Windows, ActivePython also includes PyWin32 -- a suite of Windows
    tools developed by Mark Hammond, including Win32 API integration,
    support for Python ASP, the PythonCOM system and the Pythonwin IDE.
    -=-=-=-=-=-=-=-

    On Windows, it is more the other way around... PythonWin is a
    demonstrator of what can be done /using/ the Win32API libraries...
    --
    > ============================================================== <
    > | Wulfraed Dennis Lee Bieber KD6MOG <
    > | Bestiaria Support Staff <
    > ============================================================== <
    > Home Page: <http://www.dm.net/~wulfraed/> <
    > Overflow Page: <http://wlfraed.home.netcom.com/> <
     
    Dennis Lee Bieber, Feb 4, 2006
    #12
  13. Guest

    Goodness, you're a nice friendly lot aren't you!? I saw that and I
    realise that ActivePython COMES with support for Windows. But it
    doesn't say that it forces scripts you create with it to load modules
    you haven't implicitly imported yourself! It doesn't say that a
    script might run in PythonWin but not in the command line python.

    ************
    <duh> From the help system:

    -=-=-=-=-=-=-=-
    On Windows, ActivePython also includes PyWin32 -- a suite of Windows
    tools developed by Mark Hammond, including Win32 API integration,
    support for Python ASP, the PythonCOM system and the Pythonwin IDE.
    -=-=-=-=-=-=-=-
    ************
     
    , Feb 4, 2006
    #13
  14. On 3 Feb 2006 23:17:36 -0800, declaimed the
    following in comp.lang.python:

    > Goodness, you're a nice friendly lot aren't you!? I saw that and I
    > realise that ActivePython COMES with support for Windows. But it
    > doesn't say that it forces scripts you create with it to load modules
    > you haven't implicitly imported yourself! It doesn't say that a
    > script might run in PythonWin but not in the command line python.
    >

    The key is that PythonWin is NOT loading the modules "for your
    script"... It loaded those modules for ITSELF -- the whole GUI of
    PythonWin is based on the Win32api; when you ran your script from within
    PythonWin, you had ITS environment as part of your global namespace.

    That's what I meant by "reverse"; without the Win32api modules,
    there is NO PythonWin IDE...

    Didn't you wonder about how PythonWin was able to do the pop-up
    assistance when you typed something like "win32api."? If you've never
    executed an import for a module, and PythonWin gives that help, then
    PythonWin had already, at some level, loaded the module for its own use.
    Where it is in the namespace I don't really know -- only that some are
    in use by PythonWin from the start.

    Oh, and even if you do perform an import in the interactive window,
    that action, too, makes the module available to all scripts being
    edited/run within that session.

    --
    > ============================================================== <
    > | Wulfraed Dennis Lee Bieber KD6MOG <
    > | Bestiaria Support Staff <
    > ============================================================== <
    > Home Page: <http://www.dm.net/~wulfraed/> <
    > Overflow Page: <http://wlfraed.home.netcom.com/> <
     
    Dennis Lee Bieber, Feb 4, 2006
    #14
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. stephan
    Replies:
    0
    Views:
    445
    stephan
    Jul 30, 2003
  2. John F Dutcher
    Replies:
    0
    Views:
    418
    John F Dutcher
    Dec 2, 2003
  3. Ze'ev
    Replies:
    1
    Views:
    406
    Ze'ev
    Jun 17, 2007
  4. Randell D.
    Replies:
    7
    Views:
    161
    Randell D.
    Oct 26, 2003
  5. Larry Lindstrom
    Replies:
    19
    Views:
    1,310
    Jonathan N. Little
    Jun 12, 2012
Loading...

Share This Page