0

Since on most linux distributions tkinter comes in a different package I have difficulties installing it on my university computer, where we don't have root access.

I get the following error:

/usr/bin/python3: Error while finding spec for 'tkinter.__main__' (<class 'ImportError'>: 
No module named '_tkinter', please install the python3-tk package);

I have found this answer: https://stackoverflow.com/a/10015546/2898702 Then I compiled and deployed TCL and TK in /home/<user>/.local However the last step python setup.py build seems to expect, that the python interpreter is also installed in a user directory, which is not the case for me.

Is there a way to install TCL and TK without also installing the python interpreter locally? Preferably using pip or easy_install.

In case it is relevant, the distribution seems to be linux mint. Uname -a gives me: Linux pc404 4.4.0-59-generic #80~14.04.1-Ubuntu SMP Fri Jan 6 18:02:23 UTC 2017 i686 i686 i686 GNU/Linux

G.G
  • 899
  • 6
  • 15

1 Answers1

1

For day to day working with Python, even in unrestricted environments, the way to go is to use "virtualenv", which creates a new Python environment in a user controlled folder, and you are then able to install any Python packages you want, regardless of what is available for the system. Since you have a working compiler environment, that works for almost everything.

However, tkinter itself is not available for pip install, since it is expected to come along core Python stdlib (it is about time Linux distributions would stop the idea of leaving it out - it is not like the 5MB maximum it uses would make a difference, when compared to the harm it does by not being there by default. Even customizing the Python package and creating the new one is likely more effort than it saves from anyone).

Anyway, you might try building Python in your local directory - if the system has a compiler, it probably would just work: download the tar.gz source from python.org, uncompress it and just do "./configure --prefix=/home/user/python36" . Now even when that works, it is nice to use virtualenvs for your projects.

Otherwise, you should try to find a pre-compiled Python for the specific Linux distribution, or, see in the instuctions for your package manager, if you can install Python and other packages in a different system root directory, under your control.

Anther alternative, if you have another Linux you have control, build it to a USB stick, and at the University lab, just use the ln command to link it to whatever was the target directory where you built it - that would work as a portable stick.

jsbueno
  • 99,910
  • 10
  • 151
  • 209