I am attempting to upgrade to Python 2.6.2 from Python 2.5. Everything installed successfully but import _tkinter fails. I then proceeded to install tcl 8.5.7 and tk 8.5.7 and reinstall Python 2.6.2 after making sure the appropriate directory was in the included directories list in the setup.py file.

Any idea what I am missing?

I am running Scientific Linux which is a variant of Red Hat

Recommended Answers

All 8 Replies

Normally you can find _tkinter.pyd in Windows folder C:\Python25\DLLs. See if you have a similar Python26 folder on your Linux machine. Not quite sure what a DLL is called on Linux or if a .pyd file exists for it. Might need to do a file search for _tkinter.*

Well this is Linux not Windows so there aren't any DLLs, but it appears that both library folders contain the files "lib-tk"

These exist in /usr/local/lib/Python2.5 and /usr/local/lib/Python2.6

Also in /usr/local/lib exists Tcl8.5 and Tk8.5

Try to do a file search for _tkinter.*

How did you instal Python26? Did you use the package installer or roll your own?

How did you instal Python26? Did you use the package installer or roll your own?

I installed my own using the default installation i.e. no changes to the setup file or anything like that.

I was not able to find a _tkinter file in any folders in /usr/local. Where else should I look?

Sorry if this seems basic, I'm a C++ programmer by trade, but need to use Python for another project

I don't have access to a Linux machine right now.

My question is, why would you need to use Python26? It is a bridging version to test some Python3 thingies, otherwise it does not improve on Python25 (latest version 2.5.4).

I wanted to use Python26 in order to have access to the Priority Queues that are part of the Queue library as of Python26.

In Python25 the module heapq uses priorityqueue algorithms. Take a short look if it will do what you want. Here is an example ...

# using module heapq to work with priority queues

import heapq

heap = []
# typical priority queue simulation
data = [(1, 'J'), (4, 'N'), (3, 'H'), (2, 'O')]
for item in data:
    # push data in order onto the heap
    heapq.heappush(heap, item)

print(heap)  # [(1, 'J'), (2, 'O'), (3, 'H'), (4, 'N')]

# testing ...
while heap:

""" my output ...

These exist in /usr/local/lib/Python2.5 and /usr/local/lib/Python2.6
Also in /usr/local/lib exists Tcl8.5 and Tk8.5

/uar/local/lib is not always in $PATH (enter $PATH in the terminal and see what prints).
You can key in
export PATH=$PATH:/usr/lib/:/usr/local/lib:/usr/local/bin
or whatever you want to add, and also add that line to the ~/.bashrc file so it will be added whenever you log in. You could also try Active State's version as it comes with Tkinter and Tix http://www.activestate.com/activepython/

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.