Dear FLUKA experts,
I’m installing flair on a new Mac. I followed every step in https://flair.web.cern.ch/flair/download.html. However, when I type in flair in Terminal, it gave error message:
Traceback (most recent call last):
File “/Users/z/FLUKA/flair-3.0/flair.py”, line 70, in
import tkinter as tk
File “/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.7/lib/python3.7/tkinter/init.py”, line 36, in
import _tkinter # If this fails your Python may not be configured for Tk
ModuleNotFoundError: No module named ‘_tkinter’
And here is the python packages I installed using macport:
sudo port install python37
sudo port select --set python3 python37
sudo port install py37-tkinter
sudo port install py37-Pillow
sudo port install py37-numpy
sudo port install py37-matplotlib +tkinter
sudo port install py37-scipy
sudo port install py37-pydicom
Thanks @Ephemera,
The setup seems fine, except that you have both py3.7 and py3.8.
Unless you need for specific reasons, I have experience that the two versions can create problem.
Can you also provide the output of this command? port select --summary
Thanks, luigi
Hi @Ephemera,
I guess that you still get the same error.
We have the same Macports setup, so I don’t think there is any problem there.
What I do not understand is why is the called the python from XCode and not the one from Macports.
So there is something wrong in the environment configuration.
Could you possibly check the output of these two commands? which -a python3
and env | grep PATH
Could you also possibly make a test in a new Terminal?
Cheers, luigi
Dear Luigi ,
Yes. I got the same error.
The output of which -a python3 is: /usr/bin/python3 /opt/local/bin/python3
and the output of env | grep PATH is: PATH=/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/local/bin
Hi @Ephemera,
I see that your PATH is correctly set, but the output of the which command shows the python3 instances in the reversed order.
Could you possibly make the test in a new Terminal?
I bet that the output of the which -a python3 will show the two lines inverted and then Flair should work.
Cheers luigi
Dear Luigi,
I opened up a new Terminal, and type in which -a python3, and the output is still in the same order as my last post. /usr/bin/python3 /opt/local/bin/python3
and typing in flair still gave the same error message…
I even restarted my Mac, and same thing happened.
Is there a way to manually invert their order?
Hi @Ephemera,
in a previous post, you showed that the PATH variable was correctly set.
So the first instance of python3 should be /opt/local/bin/python3 but apparently it’s not the case…
Please check if the ~/.bash_profile contains the following line export PATH="/opt/local/bin:/opt/local/sbin:$PATH"
which MacPorts should have added.
As a last recourse, you can explicitly set the PYTHON variable before launching Flair: PYTHON=/opt/local/bin/python3 <FLAIR_INSTALLATION_DIR>/flair
where <FLAIR_INSTALLATION_DIR> should be /Users/z/FLUKA/flair-3.0/ in your case
This was the problem, MacPorts did not add export PATH=/opt/local/bin:/opt/local/sbin:$PATH to my profile (in my case is ~/.zshrc.
Thank you so much for your help!!
Z.