Fix Python 3 tkinter problems on Mac using virtualenv

I think a short version of this question is: How do I get virtualenv running Python 3.5 to point to the correct version of ActiveTcl on Mac?


Here's a longer version:

I am trying to run this Korg Electribe sample editor project on a Mac. The author tested it only on Windows, and based on screenshots, it works. I managed to run the main python script fine, but as I mentioned in the problem I opened , the full window turns black after the file is uploaded.

After some research, I found that there was a known issue with Aqua Cocoa Tk , and python.org provided some instructions on how to fix tkinter for Mac OS 10.9 and higher. I tried installing both versions of ActiveTcl (8.5.18.0), as well as a new version of version 8.6.xx without success.

I am sure this is a different problem than Tkinter does not work mac osx el capitan since the script is running and the window is drawn correctly at startup. It is only after I tried to download the .all file (there is a sample file in the Github problem) that the screen turns black.

After several studies, I found this question that seems related but specific to Windows: TKinter in Virtualenv

I get the impression that if I can figure out what to install TCL_LIBRARY , I can make some kind of head, but I can not find this information for the listed packages on python.org.

Most likely, it would be useful if I could figure out which version of Tcl / Tk that tkinter points to from Python, so if anyone could help with this, I would really appreciate it.

Thanks!

+6
source share
1 answer

I managed to use tkinter in a python3 virtual environment on OSX 10.13:

  • install official OSX Python 3 from https://www.python.org/
  • install activeTcl from https://www.activestate.com/activetcl
  • creating a new virtualenv

     mkvirtualenv myenv --python=python3 
  • The location of the tkinter location in the Python3 directory. For me it was here:

     /usr/local/Cellar/python3/3.6.3/Frameworks/Python.framework/Versions/3.6/lib/python3.6/tkinter 
  • creating a symbolic link in a virtual library pointing to the tkinter location

     cd ~/.virtualenvs/myenv/lib/python3.6 ln -s /usr/local/Cellar/python3/3.6.3/Frameworks/Python.framework/Versions/3.6/lib/python3.6/tkinter tkinter 
0
source

All Articles