When I run the following code:
import Tkinter
I get this error message:
>>> import Tkinter
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python2.7/lib-tk/Tkinter.py", line 42, in <module>
raise ImportError, str(msg) + ', please install the python-tk package'
ImportError: /usr/lib/libtk8.5.so.0: invalid ELF header, please install the python-tk package
however, python-tk is installed.
$ sudo apt-get install python-tk
Reading package lists... Done
Building dependency tree
Reading state information... Done
python-tk is already the newest version.
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
Looking into why this is failing, I looked at Tkinter.py. This is the line that is failing.
try:
import _tkinter
except ImportError, msg:
raise ImportError, str(msg) + ', please install the python-tk package'
Is this a path problem? Any help would be much appreciated.
It seems like maybe that library is corrupted. Try sudo apt-get remove python-tk
, then sudo apt-get clean
so that you will re-download the package, sudo apt-get install python-tk
, and then try importing again. Another possibility is that you've somehow got your apt/sources.list messed up, and you've installed a library that is for the wrong platform.
If it is still not working after you try the above, leave a comment on this answer.
I'm not sure what the problem was, but it's been resolved. My VM got corrupted during a VMware Player update, so I had to reinstall. After the fresh install, things are working as they should. Thanks for the help.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With