You are not logged in.
Hello people,
This is my first post on the forum, I will try to make it as correct and complete as possible if you have any tips to improve my post I will gladly accept it.
I'm having trouble running code written in Python that uses Tkinter.
I will try to describe in detail my actions to facilitate the identification of the error.
I started a course at Coursera on DSP (Digital Signal Processing) where it is suggested to install a tool written in python (and a little bit of C).
link on Github:
sms-tools Github link
Using pyenv/virtualenv/virtualenvwrapper I created an environment with Python 3.7.5, as recommended in the "How to use" section of the repository.
I installed the required libraries in my environment by pip:
%pip install ipython numpy matplotlib scipy cython I compiled some C functions in the "/sms-tools/software/models/utilFunctions_C" directory with the following command:
%python compileModule.py build_ext --inplace Finally, I run the models GUI in the directory "/sms-tools/software/models_interface"
%python models_GUI.pyand I get the following message:
Traceback (most recent call last):
File "models_GUI.py", line 6, in <module>
from Tkinter import * ## notice capitalized T in Tkinter
ModuleNotFoundError: No module named 'Tkinter'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "models_GUI.py", line 9, in <module>
from tkinter import * ## notice lowercase 't' in tkinter here
File "/home/tuliochiodi/.pyenv/versions/3.7.5/lib/python3.7/tkinter/__init__.py", line 36, in <module>
import _tkinter # If this fails your Python may not be configured for Tk
ModuleNotFoundError: No module named '_tkinter' I will now describe some of my attempts to solve the problem:
Looking at Tkinter section in Python Wiki I tried installing Tcl and Tk.
%sudo pacman -S tkbut it was already installed. after that I tried installing with pip:
%pip install tkand
%pip install tkinterand the error remains the same.
I also tried to create a symlink with this code:
%ln -s /usr/lib/python3.8/lib-dynload/_tkinter.cpython-38-x86_64-linux-gnu.so _tkinter.cpython-38-x86_64-linux-gnu.so the symlink was created in the following folders:
~/.ve/Coursera_DSP/lib/python3.7/lib-dynload and
.pyenv/versions/3.7.5/lib/python3.7/lib-dynload But I still get the same error.
I appreciate if anyone has any suggestions and I apologize for the language errors, since English is not my mother tongue.
![]()
Offline
Your venv environment seems outdated, update the env first..
Offline
Your venv environment seems outdated, update the env first..
Hello qinohe, thank you for your reply!
I think they are up to date
% virtualenv --version
16.7.9
% pyenv --version
pyenv 1.2.16 If you mean that it is out of date because of Python version 3.7.5, that is the version of the environment I created, as the installation guide requires a python v3.7.x.
From https://github.com/MTG/sms-tools:
How to use
In order to use these tools you have to install python (recommended 3.7.x) and the following modules: ipython, numpy, matplotlib, scipy, and cython.
![]()
Offline
...
Looking at Tkinter section in Python Wiki I tried installing Tcl and Tk.
...
You also need to install python-pmw [Community] to use the Tkinter module.
qinohe wrote:Your venv environment seems outdated, update the env first..
Hello qinohe, thank you for your reply!
I think they are up to date
% virtualenv --version 16.7.9 % pyenv --version pyenv 1.2.16If you mean that it is out of date because of Python version 3.7.5, that is the version of the environment I created, as the installation guide requires a python v3.7.x.
From https://github.com/MTG/sms-tools:How to use
In order to use these tools you have to install python (recommended 3.7.x) and the following modules: ipython, numpy, matplotlib, scipy, and cython.
Yes, well I use 3.8 and it's working here..
Offline
You also need to install python-pmw [Community] to use the Tkinter module.
I tried installing via pacman and via pip, none worked ![]()
Yes, well I use 3.8 and it's working here..
I tried to create another environment with python 3.8, it also didn't work.
I have no idea where I should go to find out the cause of the problem ![]()
My virtual environment? My python pre installed? Problem installing tk / tcl? Any problem with Tkinter? ![]()
![]()
Offline
I tried installing via pacman and via pip, none worked
I installed 'python-pmw tk tcl' with pacman.
Do you get any messages if you try to install them with pacman ?
I tried to create another environment with python 3.8, it also didn't work.
I have no idea where I should go to find out the cause of the problem
My virtual environment? My python pre installed? Problem installing tk / tcl? Any problem with Tkinter?
Well I'm a python newbie myself, but I always update pip in venv to latest and greatest.
I do nothing in my native env., always venv, besides installing python packages with pacman..
As far as I can see I have no problems Tkinter and when I compiled 'compileModule.py' (sms-tools) I don't see the error you see.
That is, I had the error but then I installed python-pwm and all was good.
I have no real good idea with could be wrong with your env., do exactly as your told in the wiki(venv) and then follow sms-tools exactly and it should work.
Also, welcome to Arch ![]()
Offline
Well I'm a python newbie myself, but I always update pip in venv to latest and greatest.
I do nothing in my native env., always venv, besides installing python packages with pacman..As far as I can see I have no problems Tkinter and when I compiled 'compileModule.py' (sms-tools) I don't see the error you see.
That is, I had the error but then I installed python-pwm and all was good.
I have no real good idea with could be wrong with your env., do exactly as your told in the wiki(venv) and then follow sms-tools exactly and it should work.Also, welcome to Arch
I get no error compiling 'compileModule.py'. My error is importing Tkinter on python.
You had the same error as me before installing python-pwm?
Thank you qinohe ![]()
I'll keep trying, if I get to any solution I'll post here ![]()
![]()
Offline
I get no error compiling 'compileModule.py'.
You're right, I had the problem running 'python models_GUI.py '
You had the same error as me before installing python-pwm?
Yes, after installing it(pacman) I could run 'python models_GUI.py' and a GUI was opened.
Offline
Okay, I'll post here if there is any evolution.
Thank you ![]()
![]()
Offline
I uninstalled my pyenv, pyenv-virtualenv, virtualenv and virtualenvwrapper.
After that I installed conda, created a new env and it's working.
Thank you for your time qinohe ![]()
![]()
Offline
For reference:
After installing Tk on the computer, it is necessary to rerun `pyenv install <version>`.
Offline