Como posso instalar o tkinter tanto para o python 3.4 quanto para o python 3.5?

2

Como posso instalar o tkinter para o python 3.4 e o python 3.5?

Atualmente, o tkinter é instalado para o python 3.4 (ou seja, import tkinter é executado bem no interpretador do python 3.4). No entanto, não sei como instalar o tkinter para o python 3.5.

sudo apt-get install python3-tk não funciona: ele diz que python3-tk já está instalado (o que não é surpresa, pois está instalado no python 3.4).

Eu uso o Ubuntu 14.04.4 LTS x64.

python3.4:

jh@gr:/scratch/test$ python3.4
Python 3.4.3 (default, Nov 17 2016, 01:08:31)
[GCC 4.8.4] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import tkinter
>>>

python3.5:

jh@gr:/scratch/test$ python3.5
Python 3.5.2 (default, Jul 17 2016, 00:00:00)
[GCC 4.8.4] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import tkinter
Traceback (most recent call last):
  File "/usr/lib/python3.5/tkinter/__init__.py", line 36, in <module>
    import _tkinter
ImportError: No module named '_tkinter'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python3.5/tkinter/__init__.py", line 38, in <module>
    raise ImportError(str(msg) + ', please install the python3-tk package')
ImportError: No module named '_tkinter', please install the python3-tk package

Como nota de rodapé, a reinstalação do pacote python3-tk não altera a situação (ou seja, depois o tkinter funciona no python 3.4 e não no python 3.5):

sudo apt-get remove python3-tk
sudo apt-get install python3-tk
    
por Franck Dernoncourt 23.02.2017 / 19:47

2 respostas

5

Tente isto:

sudo apt-get install python3.5-tk
    
por Jenny Lee 23.02.2017 / 21:03
1

Verifique os pacotes do libpython que você instalou e, se estiver faltando, instale o libpython3.5-stdlib.

sudo apt-get install libpython3.5-stdlib
    
por ubfan1 23.02.2017 / 20:49