Modulenotfounderror no module named tkinter linux

Модуль Tkinter не найден на Ubuntu

С другой стороны.

Я проверил синаптический, Tkinter установлен. Потом я нашел это . —3—>

Если это не удается с «No module named _tkinter», ваша конфигурация Python должна быть изменена, чтобы включить этот модуль (который является модулем расширения, реализованным в C). Не редактируйте модули / настройки (они устарели). Возможно, вам придется установить Tcl и Tk (при использовании RPM также установите-devel RPMs) и / или отредактировать setup.py скрипт для указания в правильные места, где установлен Tcl/Tk. Если вы устанавливаете Tcl / Tk в местах по умолчанию, просто повторный запуск «make» должен создать расширение _tkinter.

Я предполагаю, что tkinter по-прежнему связан со старым python на моем ПК. Как изменить это, чтобы python3 мог использовать tkinter?

12 ответов

поскольку вы упомянули synaptic, я думаю, что вы на Ubuntu. Вам, вероятно, нужно запустить update-python-modules обновить модуль Tkinter для Python 3.

редактировать: запуск обновления-python-modules

во-первых, убедитесь, что у вас есть python-support установлено:

затем запустите update-python-modules С -a возможность перестроить все модули:

Я не могу гарантировать, что все ваши модули будут построены хотя, поскольку есть некоторые изменения API между Python 2 и Python 3.

то, что работало для меня в Ubuntu было на самом деле просто:

Источник

Unable to run IDLE: No module named ‘_tkinter’

when i run «idle3.8» i get this error:

I have installed every tkinter packages but i get this error again. and when I have imported tkinter and I get this error:

But I can import tkinter on python 2

my operating system is fedora

my python version is:3.8.2

1 Answer 1

Here is step by step guide to make IDLE and tkinter work on macOS Catalina. Should be easily adapted to Linux:

  1. install tcl-tk with Homebrew. In shell run brew install tcl-tk
  2. in shell run echo ‘export PATH=»/usr/local/opt/tcl-tk/bin:$PATH»‘ >>

/.zshrc
reload shell by quitting Terminal app or run source

/.zshrc

  • after reloaded check that tck-tk is in $PATH . Run echo $PATH | grep —color=auto tcl-tk . As the result you should see your $PATH contents with tcl-tk highlighted
  • now we run three commands from Homebrew’s output from step #1
    1. in shell run export LDFLAGS=»-L/usr/local/opt/tcl-tk/lib»
    2. in shell run export CPPFLAGS=»-I/usr/local/opt/tcl-tk/include»
    3. in shell run export PKG_CONFIG_PATH=»/usr/local/opt/tcl-tk/lib/pkgconfig»
  • if you have your Python version already installed with pyenv then uninstall it with pyenv uninstall . E.g. pyenv uninstall 3.8.2
  • set environment variable that will be used by python-build . In shell run PYTHON_CONFIGURE_OPTS=»—with-tcltk-includes=’-I/usr/local/opt/tcl-tk/include’ —with-tcltk-libs=’-L/usr/local/opt/tcl-tk/lib -ltcl8.6 -ltk8.6′» Note: in future use tck-tk version that actually installed with Homebrew. At the moment of posting 8.6 was the actual
  • finally install Python with pyenv with pyenv install . E.g. pyenv install 3.8.2
  • Test

    1. in shell run pyenv global
    2. now check IDLE. In shell run idle . You should see IDLE window without any warnings and «text printed in red».

    1. now check tkinter . In shell run python -m tkinter -c «tkinter._test()» . You should see test window like on the image:

    My environment:

    check this is something went wrong executing steps above:

    1. macOS Catalina
    2. zsh (included in macOS Catalina) = «shell» above
    3. Homebrew (installed with instructions from Homebrew official website)
    4. pyenv (installed with Homebrew and PATH updated according to pyenv official readme from GitHub)
    5. Python 3.8.x — 3.9.x (installed with pyenv install command)

    Источник

    Python/Tkinter : ModuleNotFoundError: No module named ‘_tkinter’

    This is my first post StackOverflow, 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). I’m using Arch Linux.

    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»

    and I get the following message:

    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 tk

    but it was already installed. after that I tried installing with pip:

    %pip install tkinter

    and 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:

    But I still get the same error.

    I appreciate it if anyone has any suggestions and I apologize for the language errors since English is not my mother tongue.

    After an incessant search on the internet, I believe the problem is related to pyenv and TCL/TK. I don’t understand much about the subject but I suspect that in the creation of the environment by virtualenv python has lost the connection with TCL/TK. Does that make any sense?

    4 Answers 4

    Here is step by step guide to make IDLE and tkinter work. Working for me on macOS Catalina. Should be easily adapted to Linux environment:

    1. install tcl-tk with Homebrew. In shell run brew install tcl-tk
    2. in shell run echo ‘export PATH=»/usr/local/opt/tcl-tk/bin:$PATH»‘ >>

    /.zshrc
    reload shell by quitting Terminal app or run source

    /.zshrc

  • after reloaded check that tck-tk is in $PATH . Run echo $PATH | grep —color=auto tcl-tk . As the result you should see your $PATH contents with tcl-tk highlighted
  • now we run three commands from Homebrew’s output from step #1
    1. in shell run export LDFLAGS=»-L/usr/local/opt/tcl-tk/lib»
    2. in shell run export CPPFLAGS=»-I/usr/local/opt/tcl-tk/include»
    3. in shell run export PKG_CONFIG_PATH=»/usr/local/opt/tcl-tk/lib/pkgconfig»
  • if you have your Python version already installed with pyenv then uninstall it with pyenv uninstall . E.g. pyenv uninstall 3.8.2
  • set environment variable that will be used by python-build . In shell run PYTHON_CONFIGURE_OPTS=»—with-tcltk-includes=’-I/usr/local/opt/tcl-tk/include’ —with-tcltk-libs=’-L/usr/local/opt/tcl-tk/lib -ltcl8.6 -ltk8.6′» Note: in future use tck-tk version that actually installed with Homebrew. At the moment of posting 8.6 was the actual
  • finally install Python with pyenv with pyenv install . E.g. pyenv install 3.8.2
  • Test

    1. in shell run pyenv global
    2. now check IDLE. In shell run idle . You should see IDLE window without any warnings and «text printed in red».

    1. now check tkinter . In shell run python -m tkinter -c «tkinter._test()» . You should see test window like on the image:

    My environment:

    check this is something went wrong executing steps above:

    1. macOS Catalina
    2. zsh (included in macOS Catalina) = «shell» above
    3. Homebrew (installed with instructions from Homebrew official website)
    4. pyenv (installed with Homebrew and PATH updated according to pyenv official readme from GitHub)
    5. Python 3.8.x — 3.9.x (installed with pyenv install command)

    Источник

    matplotlib error — no module named tkinter

    I tried to use the matplotlib package via Pycharm IDE on windows 10. when I run this code:

    I get the following error:

    I know that in python 2.x it was called Tkinter, but that is not the problem — I just installed a brand new python 3.5.1.

    EDIT: in addition, I also tried to import ‘tkinter’ and ‘Tkinter’ — neither of these worked (both returned the error message I mentioned).

    18 Answers 18

    For Linux

    Debian based distros:

    RPM based distros:

    For windows:

    For Windows, I think the problem is you didn’t install complete Python package. Since Tkinter should be shipped with Python out of box. See: http://www.tkdocs.com/tutorial/install.html . Good python distributions for Windows can be found by the companies Anaconda or ActiveState.

    Test the python module

    p.s. I suggest installing ipython, which provides powerful shell and necessary packages as well.

    if you dont want to use tkinter at all.

    Also dont forget to use %matplotlib inline at the top of your notebook if using one.

    EDIT: agg is a different backend like tkinter for matplotlib.

    For Windows users, there’s no need to download the installer again. Just do the following:

    1. Go to start menu, type Apps & features,
    2. Search for «python» in the search box,
    3. Select the Python version (e.g. Python 3.8.3rc1(32-bit)) and click Modify,
    4. On the Modify Setup page click Modify,
    5. Tick td/tk and IDLE checkbox (which installs tkinter) and click next.

    Wait for installation and you’re done.

    On Centos, the package names and commands are different. You’ll need to do:

    Источник

    Arch Linux

    You are not logged in.

    #1 2020-01-29 20:25:05

    Python/Tkinter : ModuleNotFoundError: No module named ‘_tkinter’

    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).

    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:

    I compiled some C functions in the «/sms-tools/software/models/utilFunctions_C» directory with the following command:

    Finally, I run the models GUI in the directory «/sms-tools/software/models_interface»

    and I get the following message:

    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.

    but it was already installed. after that I tried installing with pip:

    and the error remains the same.

    I also tried to create a symlink with this code:

    the symlink was created in the following folders:

    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.

    #2 2020-01-29 20:51:00

    Re: Python/Tkinter : ModuleNotFoundError: No module named ‘_tkinter’

    Your venv environment seems outdated, update the env first..

    #3 2020-01-29 21:29:09

    Re: Python/Tkinter : ModuleNotFoundError: No module named ‘_tkinter’

    Your venv environment seems outdated, update the env first..

    Hello qinohe, thank you for your reply!

    I think they are up to date

    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.

    #4 2020-01-30 00:57:52

    Re: Python/Tkinter : ModuleNotFoundError: No module named ‘_tkinter’

    .
    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.

    Your venv environment seems outdated, update the env first..

    Hello qinohe, thank you for your reply!

    I think they are up to date

    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.

    Yes, well I use 3.8 and it’s working here..

    #5 2020-01-30 12:48:25

    Re: Python/Tkinter : ModuleNotFoundError: No module named ‘_tkinter’

    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?

    #6 2020-01-30 14:12:24

    Re: Python/Tkinter : ModuleNotFoundError: No module named ‘_tkinter’

    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

    #7 2020-01-30 14:35:32

    Re: Python/Tkinter : ModuleNotFoundError: No module named ‘_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

    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

    Источник

    Читайте также:  Wallpaper engine не запускается с windows
    Оцените статью