Confusion between Python and Xojo

  1. ‹ Older
  2. 7 days ago

    Beatrix W

    Aug 9 Pre-Release Testers Europe (Germany)

    The result is: /usr/bin/python

    But this is on my computer. I have a built app - with Py2App - that has it's own version of Python so that the users don't have to install Python.

  3. Beatrix W

    Aug 9 Pre-Release Testers Europe (Germany)

    There is also no Python command. I have a very simple shell command:

    dim PythonShell as new Shell
    PythonShell.Mode = 0
    PythonShell.Execute(PathToPython.ShellPath + " " + tempFile.ShellPath)
  4. Greg O

    Aug 9 Xojo Inc Somewhere near Raleigh, NC

    Ok, so then use

    PathToPython.Parent.ShellPath
  5. Beatrix W

    Aug 9 Pre-Release Testers Europe (Germany)

    No success:

    PythonShell.Execute("PYTHONPATH='" + PathToPython.Parent.ShellPath + "';PYTHONHOME ='" + PathToPython.Parent.ShellPath + "';" + PathToPython.ShellPath + " " + tempFile.ShellPath)

    bash: PYTHONHOME: command not found
    Fatal Python error: Py_Initialize: unable to load the file system codec
    zipimport.ZipImportError: can't decompress data; zlib not available

    Current thread 0x00007fff72d82000 (most recent call first):
    bash: line 1: 78995 Abort trap: 6 /Users/beatrixwillius/Documents/Development/Mail\ Archiver/code\ current/Mail\ Archiver\ X.debug.app/Contents/Library/Helpers/fix_encoding.app/Contents/MacOS/fix_encoding /private/var/folders/yr/t1mywwrs1s1d0qv8cwv928240000gn/T/TemporaryItems/com.mothsoftware.mailarchiverx\-temp11

    Then I tried without PYTHONHOME:

    PythonShell.Execute("PYTHONPATH='" + PathToPython.Parent.ShellPath + "';" + PathToPython.ShellPath + " " + tempFile.ShellPath)

    Fatal Python error: Py_Initialize: unable to load the file system codec
    zipimport.ZipImportError: can't decompress data; zlib not available

    Current thread 0x00007fff72d82000 (most recent call first):
    bash: line 1: 79609 Abort trap: 6 /Users/beatrixwillius/Documents/Development/Mail\ Archiver/code\ current/Mail\ Archiver\ X.debug.app/Contents/Library/Helpers/fix_encoding.app/Contents/MacOS/fix_encoding /private/var/folders/yr/t1mywwrs1s1d0qv8cwv928240000gn/T/TemporaryItems/com.mothsoftware.mailarchiverx\-temp12

  6. Greg O

    Aug 9 Xojo Inc Somewhere near Raleigh, NC
    Edited 7 days ago

    Don’t use single quotes.

  7. Björn E

    Aug 9 Pre-Release Testers, Xojo Pro Iceland
    Edited 7 days ago

    @Beatrix W @Greg OLone : thanks, I'll try this.

    @Björn Einhugur: can I use the plugin at the customer without having Python 3 installed? For myself this is no problem. I can't have my users install Python.

    As far as I know then you always need to install Python to run any sort of Python. (Including when running it from Xojo)

    Unless the OS has it installed of course.

  8. Alberto D

    Aug 9 Pre-Release Testers, Xojo Pro

    I see that zlib is not available. Do your app supply zlib? I can't find zlib. Does Python install zlib?

  9. Beatrix W

    Aug 9 Pre-Release Testers Europe (Germany)

    @Greg OLone : no change.

    @Björn Eiacute;ksson : that's what Py2App or PyInstaller are for. They make a sort of runtime environment for Python and bundle this into an application.

    @Alberto de Poo: the zlib is not the problem. Executing the same command

    /Users/beatrixwillius/Documents/Development/Mail\ Archiver/Classes/Build\ Automation/fix_encoding.app/Contents/MacOS/fix_encoding /Users/beatrixwillius/Desktop/filemaker.eml

    from Terminal and not from within the Xojo shell works fine.

  10. Alberto D

    Aug 9 Pre-Release Testers, Xojo Pro
    Edited 7 days ago

    The path to zlib could be the problem. The path from Terminal and the path from Xojo shell are different.

    Edit: where is zlib on your system?

  11. Beatrix W

    Aug 9 Pre-Release Testers Europe (Germany)

    @Alberto de Poo: the zlib is in the app. The app thinks that Python is somewhere else and can't find the zlib. But I don't know how to point the app to the correct Python version.

  12. Alberto D

    Aug 9 Pre-Release Testers, Xojo Pro

    Ok, so how about executing bash yourapp instead of your app directly?

    Like Kem commented here: https://forum.xojo.com/48796-shell-in-high-sierra-10-13-5/p1#p396129

  13. Björn E

    Aug 9 Pre-Release Testers, Xojo Pro Iceland

    You might be able to put simply the Python directory into your Xojo App. (I have not tried it)

  14. @Björn Eiacute;ksson You might be able to put simply the Python directory into your Xojo App. (I have not tried it)

    You can certainly do that with PyPy .

  15. Beatrix W

    Aug 9 Pre-Release Testers Europe (Germany)

    @Alberto de Poo: that certainly looks perverted but less so than the ideas I was toying with. For instance, I can do a "do shell script" from an AppleScript. But this needs a fixed script. And I read about dockerizing Python (shudder).

    @Steve Wilson and @Björn Eiacute;ksson : I'll keep copying Python into my app in mind.

  16. 6 days ago

    Beatrix W

    Aug 10 Pre-Release Testers Europe (Germany)

    No dice. Even with Alberto's idea the error message is the same. I also tried to set the PYTHONPATH to the exact framework path

    PYTHONPATH="/Users/beatrixwillius/Documents/Development/Mail\ Archiver/code\ current/Mail\ Archiver\ X.debug.app/Contents/Library/Helpers/fix_encoding.app/Contents/Frameworks/Python.framework/Versions/3.6"

    But this also doesn't help.

    In regards to copying Python into my app: Urgh... no. The Pypy looks like a different flavor of Python. Do I need the bin directory or everything? This is just too confusing to a newbie.

  17. Beatrix W

    Aug 10 Pre-Release Testers Answer Europe (Germany)

    Head meets desk: the problem looks like a Xojo bug. I was playing around when I noticed that the Python app before copying worked and after copying the app into Xojo it didn't work anymore. On checking the Finder I saw that the app shrank from 20 MB to 13 MB.

  18. Alberto D

    Aug 10 Pre-Release Testers, Xojo Pro

    So you do a CopyFile build step and the file shrinks from 20 MB to 13 MB? That's weird.

    Can you change the 13 MB file with the 20 MB file back, and it works? Or did you find any other way to make it work?

  19. Beatrix W

    Aug 10 Pre-Release Testers Europe (Germany)

    Yes, I copied the app first manually and everything worked fine. I'm now using an IDE script with "ditto" to copy the app. I still need to create Feedback issue.

  20. 3 days ago

    Sam R

    Aug 12 Pre-Release Testers, Xojo Pro Hengchun, Pingtung, Taiwan

    Can't help with this, but trying writing Xojo code instead of GLSL in Quartz Composer, it doesn't tell you what's wrong, just never works!

  21. Beatrix W

    Aug 12 Pre-Release Testers Europe (Germany)

    ???

    Most of us get affected by age. I'm always glad when it's not just me :-)

or Sign Up to reply!