• Re: Crash when launching python

    From Stefan Ram@21:1/5 to Guenther Sohler on Wed Sep 4 15:52:28 2024
    Guenther Sohler <guenther.sohler@gmail.com> wrote or quoted:
    Is it possible to turn on debugging and to display on the console, where >python is loading files from ?

    The "-v" flag? It's like a snitch for module loading. It'll spill
    the beans on where each module's coming from - whether it's a file
    or baked right into Python. Stack those "-v"s for the full 411.

    Now, if you're feeling extra Californian, you can set the
    "PYTHONVERBOSE" environment variable to some integer. It's like
    hitting the "-v" button multiple times, but with that laid-back
    West Coast vibe.

    Oh, and get this - "sys.settrace(tracefunc)" is like the
    ultimate stalker for your code. It lets you set up a trace
    function that'll tail your Python source code closer than
    paparazzi on Rodeo Drive. Perfect for when you wanna debug
    your code like you're solving a Hollywood mystery!

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Barry Scott@21:1/5 to All on Wed Sep 4 20:48:21 2024
    On 4 Sep 2024, at 16:27, Guenther Sohler via Python-list <python-list@python.org> wrote:

    Is it possible to turn on debugging and to display on the console, where python is loading files from ?


    I assume you have a .app that is then packaged into a .dmg.

    It will be the .app that you need to either build with a debug version of your code
    or after building the .app edit the debug code into it.

    Do you know that .app files are a tree of files?
    You can right-click on an .app in Finder and it will have a "Show Package Context" option.

    Or using the terminal and you can:
    cd <appname>.app/Contents

    then have a look around.

    Beware that you cannot use print to stdout for a .app as its stdin/stdout do not go anywhere useful.
    What I do is use code like this in the main function:

    sys.stdout = open( '/home/barry/debug.log', 'w', 1 )
    sys.stderr = sys.stdout

    Now you can use print(); look in the debug.log to see what happened.
    Also any tracebacks will end up in the debug.log.

    Barry

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From dn@21:1/5 to Guenther Sohler via Python-list on Thu Sep 5 07:25:13 2024
    On 5/09/24 03:27, Guenther Sohler via Python-list wrote:
    Hi,

    My "Project" is to integrate python support into OpenSCAD. It runs quite well, but
    there are still issues on MacOS. On My MacOS it works, but it crashes when
    I ship
    the DMG files.
    It looks very much like python is not able to find the "startup" python
    files and therefore crashes.

    Is it possible to turn on debugging and to display on the console, where python is loading files from ?


    (am not a Mac user)

    Starting with 'the basics', are you familiar with:
    5. Using Python on a Mac https://docs.python.org/3/using/mac.html
    (and the more general preceding sections)

    This doc likely includes mention of such parameters:
    1.2. Environment variables https://docs.python.org/3/using/cmdline.html#environment-variables

    Here is a library for programmatic manipulation:
    site — Site-specific configuration hook https://docs.python.org/3/library/site.html#module-site

    Please let us know how things progress...

    --
    Regards,
    =dn

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Greg Ewing@21:1/5 to Barry Scott on Thu Sep 5 13:25:08 2024
    On 5/09/24 7:48 am, Barry Scott wrote:
    Beware that you cannot use print to stdout for a .app as its stdin/stdout do not go anywhere useful.

    You can invoke the executable inside the package from the Terminal.

    Normally it's in the <appname>.app/Contents/MacOS subdirectory. The name varies, but there's usually just one executable file in there. Run that
    from a shell and you should see anything written to stdout or stderr.

    --
    Greg

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Barry@21:1/5 to All on Thu Sep 5 14:51:01 2024
    On 5 Sep 2024, at 02:32, Greg Ewing via Python-list <python-list@python.org> wrote:

    Normally it's in the <appname>.app/Contents/MacOS subdirectory. The name varies, but there's usually just one executable file in there. Run that
    from a shell and you should see anything written to stdout or stderr.

    I recall that does not always work for app code that expects the macOS options that are passed in when launching from GUI.

    Barry

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)