unable to import PySimpleGUI
18,934
Now I am able to solve the issue, for that I used pyenv and install python through pyenv.
I used the following steps:
curl -L https://raw.githubusercontent.com/yyuu/pyenv-installer/master/bin/pyenv-installer | bash
sudo apt update && sudo apt upgrade
sudo apt-get install -y make build-essential libssl-dev zlib1g-dev libbz2-dev libreadline-dev libsqlite3-dev wget curl llvm libncurses5-dev git
Add to ~/.bashrc
export PATH="~/.pyenv/bin:$PATH"
eval "$(pyenv init -)"
eval "$(pyenv virtualenv-init -)"
Reload bashrc
source ~/.bashrc
Install python latest version
pyenv install 3.7.0
list python versions
pyenv versions
set global version
pyenv global 3.7.0
check python version
python -V
install PySimpleGUI
pip3 install PySimpleGUI
That's it, now I am able to import PySimpleGUI.
import PySimpleGUI
Related videos on Youtube
Comments
-
2017kamb almost 2 years
I am trying to explore PySimpleGUI. Following this link PySimpleGUI
But when I do,
import PySimpleGUI
getting error as,
Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/usr/local/lib/python3.7/site-packages/PySimpleGUI/__init__.py", line 2, in <module> from .PySimpleGUI import * File "/usr/local/lib/python3.7/site-packages/PySimpleGUI/PySimpleGUI.py", line 4, in <module> import tkinter as tk File "/usr/local/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 tried,
sudo apt-get install python3-tk and sudo apt-get install python3.7-tk
but could not get rid of the above mentioned error.
My current system details:
OS - Ubuntu 19.04 python - Python 3.7.3 PySimpleGUI - 3.29.0 tcl - 8.6.9
How to solve this issue?
-
Mike from PSG over 3 yearsJust to be clear, this is entirely a tkinter/system config problem. Really doesn't have anything to do with PySimpleGUI itself. If you wanted to code with tkinter, this would be the problem that would immediately happen. The same error will happen: ModuleNotFoundError: No module named '_tkinter'
-
-
2017kamb almost 5 yearsI did, sudo apt-get remove python3.7 sudo apt-get install python3.7 pip3 install PySimpleGUI but still issue is not resolved
-
Mike from PSG almost 5 yearsThis sounds like a tkinter installation problem. Take PySimpleGUI out of the equation. If you run python3 and type >>> import tkinter, and it fails, then you've still not fixed the problem. Are there problems with tk releasing on some versions on Linux?
-
Mike from PSG almost 5 yearsVirtual environments often cause these "missing package" type errors. Did you start out using a virtual environment and that's the root cause of your problem, or did you introduce them as part of the solution only?
-
2017kamb almost 5 yearsI used virtual environment as part of the solution.