为什么畅达安装传统知识不是在我的搬运工容器工作,即使它说,它安装?(Why does conda i

2019-09-26 07:17发布

我是有问题的tk在我的Python 3泊坞窗容器。

我试过了:

conda install tk

但它说,它并安装它

root@36602e2cd649:/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

但是当我去蟒蛇,并尝试将其导入它不工作:

>>> 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 (从安装Python的Tkinter的 ),但它没有工作:

root@36602e2cd649:/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

但不知道该怎么办...


有用的问题:

如何安装python-TK在我的搬运工图像

Answer 1:

您需要使用具有泊坞窗容器虚拟帧缓存的安装和运行。

本博客文章解释说,“为什么和怎么样”的投入X11为泊坞窗容器。

你可以看到他们是如何在通过他们的硒泊坞容器做entry_point.sh

#!/bin/bash
#
# IMPORTANT: Change this file only in directory Standalone!

source /opt/bin/functions.sh

export GEOMETRY="$SCREEN_WIDTH""x""$SCREEN_HEIGHT""x""$SCREEN_DEPTH"

function shutdown {
  kill -s SIGTERM $NODE_PID
  wait $NODE_PID
}

if [ ! -z "$SE_OPTS" ]; then
  echo "appending selenium options: ${SE_OPTS}"
fi

SERVERNUM=$(get_server_num)

rm -f /tmp/.X*lock

xvfb-run -n $SERVERNUM --server-args="-screen 0 $GEOMETRY -ac +extension RANDR" \
  java ${JAVA_OPTS} -jar /opt/selenium/selenium-server-standalone.jar \
  ${SE_OPTS} &
NODE_PID=$!

trap shutdown SIGTERM SIGINT
wait $NODE_PID

源,用于上面的代码是从在GitHub,该存储库SeleniumHQ /搬运工-硒 。



Answer 2:

好了,所以有一次我把一个虚拟屏幕它停止崩溃的图像:

RUN apt-get update
RUN apt-get install -y xvfb
#RUN Xvfb :1 -screen 0 1024x768x16 &> xvfb.log  &

当我跑我的码头工人的形象。



Answer 3:

与Python 3,你必须导入如下:

import tkinter   # with a small caps 't'


文章来源: Why does conda install tk not work in my docker container even though it says its installed?