Python Forum

Full Version: tkinter osx
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi! We have some scripts in Python made for Reaper (a DAW). We succesfully run it in Windows, but when it comes to mac. Seems that problem is related to tkinter module.

import tkinter
ImportError: No module named tkinter.

Using OSX 10.9.5 (tried on some others as well), installed ActiveTcl 8.6.7 and using Python 3.6.4.

Tried the Reaper forum but no luck. There are many documentation in Google and even these forums but I could not make it work. Any ideas? Thanks for the support.
Not a Mac user, but did you red this https://www.python.org/download/mac/tcltk/
they recommend ActiveTcl 8.5
also
http://bohumirzamecnik.cz/blog/2014/inst...-3-on-mac/
(Feb-08-2018, 11:55 AM)buran Wrote: [ -> ]Not a Mac user, but did you red this https://www.python.org/download/mac/tcltk/
they recommend ActiveTcl 8.5
also
http://bohumirzamecnik.cz/blog/2014/inst...-3-on-mac/

Thanks for your reply! Yep, we tried that. ActiveTcl 8.5 installed and the small testing GUI dialog works. Does that mean that script needs to be modified? They work on Windows.
(Feb-08-2018, 12:03 PM)Ganttictemp Wrote: [ -> ]the small testing GUI dialog works
if small testing dialog works, your script should work too. you said you get ImportError: No module named tkinter. Is this still the case?
Yes, it is.

Quote:Script execution error

Tracebak (most recent call last):

File "nameoffile.py", line 3, in <module>
from tkinter import *
ImportError: No module named tkinter

It is executed through Reaper. Don't know if that may interfere.
I'm not a mac user either, but you can perhaps guess if Reaper interferes by running this script through Reaper
import sys
raise RuntimeError(sys.path)
then try to understand why there is not a 'tkinter' directory in one of these directories. You can also run the same script out of Reaper to see the differences between running with Reaper or without it. You can post the output here and we may try to understand what's going on.
(Feb-08-2018, 12:32 PM)Ganttictemp Wrote: [ -> ]It is executed through Reaper. Don't know if that may interfere.
Maybe if Reaper has its own Python interpreter, different from the system-wide installed
From Reaper docs:
Quote:Python requirements
You must have Python installed on your computer and enabled in REAPER preferences (Options > Preferences > Plug-Ins > ReaScript). ReaScript should work with any version of Python between 2.7 and the current 3.x release. OS X normally comes with Python already installed. If you don't already have Python, it is available as a free download for Windows or Mac from multiple sources. For 32-bit REAPER, you need 32-bit Python (regardless of the operating system). For 64-bit REAPER, you need 64-bit Python. A list of Python distributions is here.

https://www.reaper.fm/sdk/reascript/reascript.php

Maybe you can check in Reaper prefernces and make sure you use the same python version/installation that has tkinter and for which the small test dialog works.
Hi again!

Python scripts without GUI run properly for us in Reaper. I mean, we do have Python enabled in preferences, but, yeah, I think you guys are close. Maybe we need to set it up differently.

I did run this:

import sys
raise RuntimeError(sys.path)

And all I got is references to Python 2.7, so that may be it. Supposedly, Python 3.6 is installed. We must find a way to force Reaper to use the proper one, I guess.

Somehow they are in different folders, as if OSX were using 2.7 by default. I remember something about it.

Thanks both of you! Let's see if we can manage.
(Feb-08-2018, 01:46 PM)Ganttictemp Wrote: [ -> ]And all I got is references to Python 2.7, so that may be it.
Yes, in python2 its Tkinter, not tkinter and there are other differences too. But if your tkinter is installed for 3.6 (based on the working small test window) you need to setup Reaper to work with that one