0

I need tkinter to work in my python virtualenv. Apparently, it is not a python package - can only be installed as a yum or apt-get install - and I don't root permissions on my machine.

  1. Install Tkinter without root access
  2. Install tkinter for Python

Tried recommendation in #1 and I get:

easy_install --prefix=~/.local3/ python-tk
Creating /home/<userid>/.local3/lib/python3.4/site-packages/site.py
Searching for python-tk
Reading https://pypi.python.org/simple/python-tk/
Couldn't find index page for 'python-tk' (maybe misspelled?)
Scanning index of all packages (this may take a while)
Reading https://pypi.python.org/simple/
No local packages or working download links found for python-tk
error: Could not find suitable distribution for Requirement.parse('python-tk')

URL #2 seems to have come close but does not quite close the deal:

cd ~/tcl8.5.11/unix
./configure --prefix=/home/cnel711 --exec-prefix=/home/cnel711
make
make install

cd ~/tk8.5.11/unix
./configure --prefix=/home/cnel711 --exec-prefix=/home/cnel711 --with-tcl=/home/cnel711/tcl8.5.11/unix
make
make install

Above works but how to corral it into my virtualenv setup is not clear. Is it referring to building python from sources and then latching onto that setup.py?

Has someone been able to find a proper solution?

1 Answers1

1

The approach I use is to have a local installation of Python (it totally does not need to be installed as root if you build it from sources, but you may need to tweak the build instructions, and it's too long since I did it for me to remember as it was “obvious” to me) and then build the virtual environment on top of that. This is required because the Tkinter package is part of Python's package set (that page tells a few outright lies, but none that matter to you) and is not present in PyPI.

Donal Fellows
  • 133,037
  • 18
  • 149
  • 215
  • I also have local installations of many other tools too, often so that I can configure them to use unusual sets of build-time options. – Donal Fellows Aug 27 '19 at 04:59
  • Agreed. This an acceptable solution. I also hope to deploy what I build to 20 other machines - for different users. I maybe able to influence them to download and build - but was hoping for something that is more scalable. Thanks for your reply. – navjit.brar Aug 28 '19 at 21:16