LINUX.ORG.RU

как установить tkinter?

 , ,


0

1

помогите пожалуйста установить tkinter.

в python3 я использую библиотеку matplotlib, при помощи неё рисую график, в результате создаётся файл, я его открываю и смотрю без проблем. но я хотел бы чтобы этот график выводился на экране сразу. для этого нужно подключить tkinter

я делаю следующее:

(transaction1) md@md ~/.MINT18/code/python/transaction1 $ sudo apt-get install python-tk
Чтение списков пакетов… Готово
Построение дерева зависимостей       
Чтение информации о состоянии… Готово
Предлагаемые пакеты:
  tix python-tk-dbg
Следующие НОВЫЕ пакеты будут установлены:
  python-tk
Обновлено 0 пакетов, установлено 1 новых пакетов, для удаления отмечено 0 пакетов, и 13 пакетов не обновлено.
Необходимо скачать 26,3 kB архивов.
После данной операции объём занятого дискового пространства возрастёт на 95,2 kB.
Пол:1 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 python-tk amd64 2.7.12-1~16.04 [26,3 kB]
Получено 26,3 kB за 0с (84,0 kB/s)  
Выбор ранее не выбранного пакета python-tk.
(Чтение базы данных … на данный момент установлено 218287 файлов и каталогов.)
Подготовка к распаковке …/python-tk_2.7.12-1~16.04_amd64.deb …
Распаковывается python-tk (2.7.12-1~16.04) …
Настраивается пакет python-tk (2.7.12-1~16.04) …
(transaction1) md@md ~/.MINT18/code/python/transaction1 $ sudo apt-get install python-tk
Чтение списков пакетов… Готово
Построение дерева зависимостей       
Чтение информации о состоянии… Готово
Уже установлен пакет python-tk самой новой версии (2.7.12-1~16.04).
Обновлено 0 пакетов, установлено 0 новых пакетов, для удаления отмечено 0 пакетов, и 13 пакетов не обновлено.
(transaction1) md@md ~/.MINT18/code/python/transaction1 $ whereis python-tk
python-tk:
(transaction1) md@md ~/.MINT18/code/python/transaction1 $ which python-tk

судя по всему tkinter установился. теперь я пробую импортировать его в скрипт так:

import tkinter

но после запуска скрипта получаю следующую ошибку:

(transaction1) md@md ~/.MINT18/code/python/transaction1 $ python index3.py
Traceback (most recent call last):
  File "index3.py", line 3, in <module>
    import tkinter
ModuleNotFoundError: No module named 'tkinter'

ещё я пробовал делать так:

(transaction1) md@md ~/.MINT18/code/python/transaction1 $ pipenv install tkinter
Installing tkinter…
Adding tkinter to Pipfile's [packages]…
✔ Installation Succeeded 
Pipfile.lock (a21357) out of date, updating to (757436)…
Locking [dev-packages] dependencies…
Locking [packages] dependencies…
✘ Locking Failed! 
[pipenv.exceptions.ResolutionFailure]:   File "/home/md/.local/lib/python3.5/site-packages/pipenv/resolver.py", line 61, in resolve
[pipenv.exceptions.ResolutionFailure]:       return resolve_deps(
[pipenv.exceptions.ResolutionFailure]:   File "/home/md/.local/lib/python3.5/site-packages/pipenv/utils.py", line 718, in resolve_deps
[pipenv.exceptions.ResolutionFailure]:       resolved_tree, hashes, markers_lookup, resolver = actually_resolve_deps(
[pipenv.exceptions.ResolutionFailure]:   File "/home/md/.local/lib/python3.5/site-packages/pipenv/utils.py", line 480, in actually_resolve_deps
[pipenv.exceptions.ResolutionFailure]:       resolved_tree = resolver.resolve()
[pipenv.exceptions.ResolutionFailure]:   File "/home/md/.local/lib/python3.5/site-packages/pipenv/utils.py", line 395, in resolve
[pipenv.exceptions.ResolutionFailure]:       raise ResolutionFailure(message=str(e))
[pipenv.exceptions.ResolutionFailure]:       pipenv.exceptions.ResolutionFailure: ERROR: ERROR: Could not find a version that matches threading
[pipenv.exceptions.ResolutionFailure]:       No versions found
[pipenv.exceptions.ResolutionFailure]: Warning: Your dependencies could not be resolved. You likely have a mismatch in your sub-dependencies.
  First try clearing your dependency cache with $ pipenv lock --clear, then try the original command again.
 Alternatively, you can use $ pipenv install --skip-lock to bypass this mechanism, then run $ pipenv graph to inspect the situation.
  Hint: try $ pipenv lock --pre if it is a pre-release dependency.
ERROR: ERROR: Could not find a version that matches threading
No versions found
Was https://pypi.org/simple reachable?
[pipenv.exceptions.ResolutionFailure]:       return resolve_deps(
[pipenv.exceptions.ResolutionFailure]:   File "/home/md/.local/lib/python3.5/site-packages/pipenv/utils.py", line 718, in resolve_deps
[pipenv.exceptions.ResolutionFailure]:       resolved_tree, hashes, markers_lookup, resolver = actually_resolve_deps(
[pipenv.exceptions.ResolutionFailure]:   File "/home/md/.local/lib/python3.5/site-packages/pipenv/utils.py", line 480, in actually_resolve_deps
[pipenv.exceptions.ResolutionFailure]:       resolved_tree = resolver.resolve()
[pipenv.exceptions.ResolutionFailure]:   File "/home/md/.local/lib/python3.5/site-packages/pipenv/utils.py", line 395, in resolve
[pipenv.exceptions.ResolutionFailure]:       raise ResolutionFailure(message=str(e))
[pipenv.exceptions.ResolutionFailure]:       pipenv.exceptions.ResolutionFailure: ERROR: ERROR: Could not find a version that matches threading
[pipenv.exceptions.ResolutionFailure]:       No versions found
[pipenv.exceptions.ResolutionFailure]: Warning: Your dependencies could not be resolved. You likely have a mismatch in your sub-dependencies.
  First try clearing your dependency cache with $ pipenv lock --clear, then try the original command again.
 Alternatively, you can use $ pipenv install --skip-lock to bypass this mechanism, then run $ pipenv graph to inspect the situation.
  Hint: try $ pipenv lock --pre if it is a pre-release dependency.
ERROR: ERROR: Could not find a version that matches threading
No versions found
Was https://pypi.org/simple reachable?
(transaction1) md@md ~/.MINT18/code/python/transaction1 $ pipenv graph
matplotlib==3.1.2
  - cycler [required: >=0.10, installed: 0.10.0]
    - six [required: Any, installed: 1.13.0]
  - kiwisolver [required: >=1.0.1, installed: 1.1.0]
    - setuptools [required: Any, installed: 42.0.2]
  - numpy [required: >=1.11, installed: 1.17.4]
  - pyparsing [required: >=2.0.1,!=2.1.6,!=2.1.2,!=2.0.4, installed: 2.4.5]
  - python-dateutil [required: >=2.1, installed: 2.8.1]
    - six [required: >=1.5, installed: 1.13.0]
pandas==0.25.3
  - numpy [required: >=1.13.3, installed: 1.17.4]
  - python-dateutil [required: >=2.6.1, installed: 2.8.1]
    - six [required: >=1.5, installed: 1.13.0]
  - pytz [required: >=2017.2, installed: 2019.3]
psycopg2==2.8.4
redis==3.3.11


Настраивается пакет python-tk (2.7.12-1~16.04)

судя по всему tkinter установился. теперь я пробую импортировать его в скрипт так:

import tkinter

В python2 нужно писать

import Tkinter

в python3 нужно писать

import tkinter

Определись какой tkinter тебе нужен, и на каком питоне ты пишешь

fsb4000 ★★★★★
()
Последнее исправление: fsb4000 (всего исправлений: 1)
Ответ на: комментарий от prozaik

но он не импортируется так

$ sudo apt-get install python3-tk

почувствуй разницу.

anonymous
()
Вы не можете добавлять комментарии в эту тему. Тема перемещена в архив.