5

I'm trying to create an app for a program I have written. I have no problems doing it on Windows, but I've been trying for a week to get an OSX version working. Here is what my terminal looks like:

Thomass-iMac:gene_expression Tomallama$ python3 --version
Python 3.6.6
Thomass-iMac:gene_expression Tomallama$ python3 -m PyInstaller -- 
onefile gene_expression.py
190 INFO: PyInstaller: 3.3.1
191 INFO: Python: 3.6.6
196 INFO: Platform: Darwin-15.6.0-x86_64-i386-64bit
197 INFO: wrote 
/Users/Tomallama/Desktop/Programs/gene_expression/gene_expression.spec
200 INFO: UPX is not available.
202 INFO: Extending PYTHONPATH with paths
['/Users/Tomallama/Desktop/Programs/gene_expression',
 '/Users/Tomallama/Desktop/Programs/gene_expression']
202 INFO: checking Analysis
202 INFO: Building Analysis because out00-Analysis.toc is non existent
202 INFO: Initializing module dependency graph...
203 INFO: Initializing module graph hooks...
205 INFO: Analyzing base_library.zip ...
3787 INFO: running Analysis out00-Analysis.toc
3794 INFO: Caching module hooks...
3798 INFO: Analyzing 
/Users/Tomallama/Desktop/Programs/gene_expression/gene_expression.py
4017 INFO: Loading module hooks...
4017 INFO: Loading module hook "hook-_tkinter.py"...
4020 ERROR: Tcl/Tk improperly installed on this system.
4020 INFO: Loading module hook "hook-encodings.py"...
4103 INFO: Loading module hook "hook-pydoc.py"...
4104 INFO: Loading module hook "hook-xml.py"...
4408 INFO: Looking for ctypes DLLs
4408 INFO: Analyzing run-time hooks ...
4411 INFO: Including run-time hook 'pyi_rth__tkinter.py'
4418 INFO: Looking for dynamic libraries
4510 INFO: Looking for eggs
4510 INFO: Using Python library /Library/Frameworks/Python.framework/Versions/3.6/Python
4512 INFO: Warnings written to /Users/Tomallama/Desktop/Programs/gene_expression/build/gene_expression/warngene_expression.txt
4545 INFO: Graph cross-reference written to /Users/Tomallama/Desktop/Programs/gene_expression/build/gene_expression/xref-gene_expression.html
4555 INFO: checking PYZ
4555 INFO: Building PYZ because out00-PYZ.toc is non existent
4555 INFO: Building PYZ (ZlibArchive) /Users/Tomallama/Desktop/Programs/gene_expression/build/gene_expression/out00-PYZ.pyz
4938 INFO: Building PYZ (ZlibArchive) /Users/Tomallama/Desktop/Programs/gene_expression/build/gene_expression/out00-PYZ.pyz completed successfully.
4944 INFO: checking PKG
4944 INFO: Building PKG because out00-PKG.toc is non existent
4944 INFO: Building PKG (CArchive) out00-PKG.pkg
7984 INFO: Building PKG (CArchive) out00-PKG.pkg completed successfully.
7987 INFO: Bootloader /Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/PyInstaller/bootloader/Darwin-64bit/run
7987 INFO: checking EXE
7987 INFO: Building EXE because out00-EXE.toc is non existent
7987 INFO: Building EXE from out00-EXE.toc
7988 INFO: Appending archive to EXE /Users/Tomallama/Desktop/Programs/gene_expression/dist/gene_expression
8038 INFO: Fixing EXE for code signing /Users/Tomallama/Desktop/Programs/gene_expression/dist/gene_expression
8051 INFO: Building EXE from out00-EXE.toc completed successfully.

Then, when I go into the dist folder and run the app this is what happens.

Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/PyInstaller/loader/rthooks/pyi_rth__tkinter.py", line 28, in <module>
    raise FileNotFoundError('Tcl data directory "%s" not found.' % (tcldir))
FileNotFoundError: Tcl data directory "/var/folders/2t/lv424fgn1ml7v_6xs6lkr4hh0000gn/T/_MEIPrF3eT/tcl" not found.
[6771] Failed to execute script pyi_rth__tkinter
logout
Saving session...
...copying shared history...
...saving history...truncating history files...
...completed.

[Process completed]

Like I said, this process works just find when I run it on Windows. But I can't figure out the reason for it not working on Mac. I also need to keep it using Python 3.6 because there are f-strings in the code.

Thomas Kellough
  • 143
  • 1
  • 2
  • 11
  • Have you looked at Platypus? It's a free mac application that will turn your python code into a mac app. I've used it and it works fine. – Natsfan Aug 14 '18 at 18:49
  • Hmm, no I haven't. I'll give that a shot and see if I can make that work. Thanks for the tip. – Thomas Kellough Aug 14 '18 at 18:56
  • https://sveinbjorn.org/platypus – Natsfan Aug 14 '18 at 19:00
  • The output says it's written warnings to at least one file, `warngene_expression.txt`. What's in that file? – abarnert Aug 14 '18 at 19:04
  • Anyway, it seems like PyInstaller might be confusing itself by trying too hard to limit the amount of Tcl/Tk code that it includes in the executable. (It used to err too far in the other direction…) Do you have a setup file you're using to drive it? If so, can you show it to us? – abarnert Aug 14 '18 at 19:06
  • I'm not sure what the warngene_expression.txt file is. It's not a file I created. I'm also completely stupid with Mac and all my experience is with Windows so I'm unsure of even how to find that file. I'm actually not sure what you're asking when you ask for a setup file I'm using to drive it. Is that the spec file? – Thomas Kellough Aug 14 '18 at 19:24
  • Thanks jmh for the tip on Platypus. Downloaded it and it worked like a charm! – Thomas Kellough Aug 14 '18 at 19:32
  • If I write that up as an answer will you accept it? – Natsfan Aug 14 '18 at 23:21
  • Sure. Also, do you by any chance know how to package it as one file using Platypus? When I try to add the app into my github it automatically separates it into multiple downloads. – Thomas Kellough Aug 15 '18 at 02:11
  • no I don't. in my case the app appeared on my desktop. I didn't use github. – Natsfan Aug 15 '18 at 20:55

1 Answers1

2

Explanation and a work-around can be found here: https://github.com/pyinstaller/pyinstaller/issues/3753

In short: There is a bug in PyInstaller that mishandles Tcl/Tk under OS X. Changing the code in hook-_tkinter.py made it work for me.

JoergEwald
  • 379
  • 3
  • 10