<p>That problem occurs because the <code>workspace-full-vnc</code> image uses <code>pyenv</code> and the module path is different (<a href="https://github.com/gitpod-io/workspace-images/blob/73eeb0eeba2142d04a345e9de7aff4249d7384b5/full/Dockerfile#L201" rel="nofollow noreferrer">source</a>). To use python modules, you need to install them using <code>python2</code> or <code>python3 -m pip install ...</code>.</p>

CC BY-SA 4.0
2021-01-16T23:50:53.687Z
This doesn't work. 
As pointed at [community.gitpod.io](https://community.gitpod.io/t/how-to-install-tk-and-tkinter-gitpod/274/2?u=makayabou), tkinter **has to** be installed _before_ pyenv, so it needs to be done while building workspace image.
makayabou
CC BY-SA 4.0
2020-11-16T11:44:04.860Z
2020-11-16T14:48:51.753Z
2020-11-16T14:48:51.753Z
Wulf Thimm
<p>I can't import pyton module <code>tkinter</code> in my gitpod workspace.</p>
<p>My .gitpod.Dockerfile contains:</p>
<pre><code>FROM gitpod/workspace-full-vnc
USER root
RUN apt update &amp;&amp; apt install -y python-tk python3-tk tk-dev
</code></pre>
<p>but when I run my project I get</p>
<pre><code>Traceback (most recent call last):
  File &quot;basic-screen-changer.py&quot;, line 1, in &lt;module&gt;
    import tkinter as tk
  File &quot;/home/gitpod/.pyenv/versions/3.8.6/lib/python3.8/tkinter/__init__.py&quot;, line 36, in &lt;module&gt;
    import _tkinter # If this fails your Python may not be configured for Tk
ModuleNotFoundError: No module named '_tkinter'
</code></pre>
<p><code>python --version</code> shows me <code>Python 3.8.6</code>.<br />
Installed packaged are:</p>
<pre><code>itpod /workspace/pydiag $ dpkg -l |grep ^ii |tr -s ' ' |cut -d ' ' -f2,3 |egrep '^python.*tk|^tk'
python-tk 2.7.18-1
python3-tk:amd64 3.8.5-1~20.04.1
tk 8.6.9+1
tk-dev:amd64 8.6.9+1
tk8.6 8.6.10-1
tk8.6-blt2.5 2.5.3+dfsg-4
tk8.6-dev:amd64 8.6.10-1
</code></pre>

<cicd><python>
how can I import python module tkinter in gitpod
makayabou
# how can I import python module tkinter in gitpod

(Asked by: username_0 on 2020-11-15)

I can't import pyton module tkinter in my gitpod workspace.
My .gitpod.Dockerfile contains:
FROM gitpod/workspace-full-vnc
USER root
RUN apt update && apt install -y python-tk python3-tk tk-dev

but when I run my project I get
Traceback (most recent call last):
  File "basic-screen-changer.py", line 1, in 
    import tkinter as tk
  File "/home/gitpod/.pyenv/versions/3.8.6/lib/python3.8/tkinter/__init__.py", line 36, in 
    import _tkinter # If this fails your Python may not be configured for Tk
ModuleNotFoundError: No module named '_tkinter'

python --version shows me Python 3.8.6.
Installed packaged are:
itpod /workspace/pydiag $ dpkg -l |grep ^ii |tr -s ' ' |cut -d ' ' -f2,3 |egrep '^python.*tk|^tk'
python-tk 2.7.18-1
python3-tk:amd64 3.8.5-1~20.04.1
tk 8.6.9+1
tk-dev:amd64 8.6.9+1
tk8.6 8.6.10-1
tk8.6-blt2.5 2.5.3+dfsg-4
tk8.6-dev:amd64 8.6.10-1

**Tags:** cicd, python


---

## 1 answers

### Answer by username_1 on 2020-11-16. Score: 1

That problem occurs because the `workspace-full-vnc` image uses `pyenv` and the module path is different ([source](https://github.com/gitpod-io/workspace-images/blob/73eeb0eeba2142d04a345e9de7aff4249d7384b5/full/Dockerfile#L201)). To use python modules, you need to install them using `python2` or `python3 -m pip install ...`.

> **Comments:**
> **username_0**: This doesn't work.  As pointed at [community.gitpod.io](https://community.gitpod.io/t/how-to-install-tk-and-tkinter-gitpod/274/2?u=username_0), tkinter **has to** be installed _before_ pyenv, so it needs to be done while building workspace image.  

---

