【发布时间】:2016-01-20 02:13:48
【问题描述】:
我在一个 ubuntu 可信赖的 docker 容器上安装了 python3-tk。(apt-get install python3-tk)
> python3
Python 3.4.3 (default, Oct 14 2015, 20:28:29)
[GCC 4.8.4] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import tkinter
>>> import tkinter as tk
>>>
到目前为止一切顺利。但是,由于不同的原因,我需要在同一个容器中运行加载的 python3 virtualenv。 当我激活虚拟环境时:
(env_py34)root@8a7953c24d4f:/home# python
Python 3.4.3 (default, Oct 14 2015, 20:28:29)
[GCC 4.8.4] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import tkinter as tk
Traceback (most recent call last):
File "/usr/lib/python3.4/tkinter/__init__.py", line 39, 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.4/tkinter/__init__.py", line 41, in <module>
raise ImportError(str(msg) + ', please install the python3-tk package')
ImportError: No module named '_tkinter', please install the python3-tk package
>>>
python 的版本是相同的。 为什么虚拟环境没有从python3安装继承python3-tk?如何在虚拟环境中安装 python3-tk?
【问题讨论】:
标签: python-3.x ubuntu tkinter docker