I need help installing tkFileDialog.py module in Python2.7 running in Ubuntu 11.10

Asked by Philip H. Kahn

I have numerous routines written in Python running under windows that call tkFileDialog.py. I am trying to port those programs to Python2.7 running on Ubuntu 11.10 and I realize that I need to install the package containing tkFileDialog.py I checked inside /usr/lib/python2.7 and found a directory called lib-tk that contains tkFIleDialog.py and the compiled version tkFileDialog.pyc . I think I just need to install the modules in lib-tk in Python 2.7.

This is what I have tried so far...

philip@philip-System-Product-Name:/$ sudo apt-get install /usr/lib/python2.7/lib-tk/tkFileDialog.py

and this was the response...

[sudo] password for philip:

I then entered my user password and then the console responded...

Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package /usr/lib/python2.7/lib-tk
E: Couldn't find any package by regex '/usr/lib/python2.7/lib-tk'

Given that the console said that it was finished reading package lists I do not see why it couldn't locate package /usr/lib/python2.7/lib-tk . Any help would be most appreciated.

Question information

Language:
English Edit question
Status:
Solved
For:
Ubuntu python-stdlib-extensions Edit question
Assignee:
No assignee Edit question
Solved by:
Philip H. Kahn
Solved:
Last query:
Last reply:
Revision history for this message
Philip H. Kahn (phkahn) said :
#1

I think that I may need to install all of the modules in /usr/lib/python2.7/lib-tk not just tkFileDialog.py . If this is so, would the command I should use be:

$ sudo apt-get install /usr/lib/python2.7/lib-tk *

?

Revision history for this message
Ubfan (ubfan1) said :
#2

You're probably looking for the python-tk package.
Of course, you should also have the tk package installed.

Revision history for this message
Philip H. Kahn (phkahn) said :
#3

Ubfan: I cannot find the python-tk package for installing into Python2.7 . Are packages located in /usr/lib/python2.7/ ? What is the proper syntax for installing all of the modules in /usr/lib/python2.7/lib-tk/ ? Thanks for your help.

Revision history for this message
Ubfan (ubfan1) said :
#4

Every file there is already installed. You may need to put the location into your environment variables, like PYTHONPATH, TK_LIBRARY, TCL_LIBRARY (along with some others maybe).
example:
export PYTHONPATH=/usr/lib/python2.7/lib-tk:/usr/lib/python2.7/lib-stdwin:/usr/lib/python2.7/lib-dynload:/usr/lib:
TK_LIBRARY=/usr/lib/python2.7/lib-tk:/usr/lib
TKPATH=/usr/lib/python2.7/lib-tk:/usr/lib
TCL_LIBRARY=/usr/lib
export TCL_LIBRARY TK_LIBRARY TKPATH

Put these into a file (suppose it's named "setup")
and run the file in your current shell with the dot command:
. setup

Then you may run python and it should pick up what's needed.

Revision history for this message
Philip H. Kahn (phkahn) said :
#5

Ubfan:

I created the file exactly as you wrote and executed it and then I was able to run my Python program that used tkFileDialog.py . Thank you so much.

What does the export command do? I understand the setting of the environment variables (TK_LIBRARY, TKPATH, and TCL_LIBRARY).

Thanks again for your help...

Philip

Revision history for this message
Ubfan (ubfan1) said :
#6

export promotes a shell variable to the environment so it is inherited by
subshells (i.e. running programs). see the manual pages for bash:
man bash