我在我的python 3 docker容器中遇到了tk
問題。爲什麼conda安裝tk不能在我的Docker容器中工作,即使它說它安裝了?
我想:
conda install tk
,但它說,它沒有安裝它
[email protected]:/home_simulation_research/overparametrized_experiments/pytorch_experiments# conda install tk
Fetching package metadata ...........
Solving package specifications: .
# All requested packages already installed.
# packages in environment at /opt/conda:
#
tk 8.6.7 h5979e9b_1
,但是當我去到Python,並嘗試將其導入它不起作用:
>>> import Tkinter
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named 'Tkinter'
等錯誤:
>>> import tkinter
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/opt/conda/envs/pytorch-py35/lib/python3.5/tkinter/__init__.py", line 35, in <module>
import _tkinter # If this fails your Python may not be configured for Tk
ImportError: libX11.so.6: cannot open shared object file: No such file or directory
當我運行需要它的腳本:
Traceback (most recent call last):
File "bulk_experiment_dispatcher.py", line 18, in <module>
from data_file import *
File "/home_simulation_research/overparametrized_experiments/pytorch_experiments/data_file.py", line 16, in <module>
import matplotlib.pyplot as plt
File "/opt/conda/envs/pytorch-py35/lib/python3.5/site-packages/matplotlib/pyplot.py", line 115, in <module>
_backend_mod, new_figure_manager, draw_if_interactive, _show = pylab_setup()
File "/opt/conda/envs/pytorch-py35/lib/python3.5/site-packages/matplotlib/backends/__init__.py", line 32, in pylab_setup
globals(),locals(),[backend_name],0)
File "/opt/conda/envs/pytorch-py35/lib/python3.5/site-packages/matplotlib/backends/backend_tkagg.py", line 6, in <module>
from six.moves import tkinter as Tk
File "/opt/conda/envs/pytorch-py35/lib/python3.5/site-packages/six.py", line 92, in __get__
result = self._resolve()
File "/opt/conda/envs/pytorch-py35/lib/python3.5/site-packages/six.py", line 115, in _resolve
return _import_module(self.mod)
File "/opt/conda/envs/pytorch-py35/lib/python3.5/site-packages/six.py", line 82, in _import_module
__import__(name)
File "/opt/conda/envs/pytorch-py35/lib/python3.5/tkinter/__init__.py", line 35, in <module>
import _tkinter # If this fails your Python may not be configured for Tk
ImportError: libX11.so.6: cannot open shared object file: No such file or directory
我試圖apt-get install python-tk
(從Install tkinter for Python),但它沒有工作:
[email protected]:/home_simulation_research/overparametrized_experiments/pytorch_experiments# apt-get install python-tk
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package python-tk
我試圖運行ENTERYPOINT
爲一體建議的答案,但它給我多了一些錯誤:
/path/fake_gui.sh: 8: /home_simulation_research/overparametrized_experiments/docker_files/runtime/fake_gui.sh: source: not found
/path/fake_gui.sh: 12: /home_simulation_research/overparametrized_experiments/docker_files/runtime/fake_gui.sh: function: not found
/path/fake_gui.sh: 13: kill: invalid signal number or name: SIGTERM
/path/fake_gui.sh: 15: /home_simulation_research/overparametrized_experiments/docker_files/runtime/fake_gui.sh: Syntax error: "}" unexpected
,但不知道該怎麼辦...
有用的問題:
How to install python-tk in my docker image
仍然引發一個錯誤,但是當然要感謝那麼重要:'import _tkinter#如果這個失敗,你的Python可能不會被配置爲Tk ImportError:libX11.so.6:無法打開共享目標文件:沒有這樣的文件或目錄「...把原始問題的整個錯誤。 –