问题
While being new to python and not having a lot of knowldege on it I got stuck in a problem. I am trying to add a GUI input box and I found out that the way you do that is by using a module called tkiner. While I was trying to install it on my arch linux machine through the ActivePython package I got the following error:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python3.6/tkinter/__init__.py", line 36, in <module>
import _tkinter # If this fails your Python may not be configured for Tk
ImportError: libtk8.6.so: cannot open shared object file: No such file or directory
shell returned 1\
This might be a common problem but because of my lack of knowldege I bare you to be as simple as possible with me...thank you!
回答1:
All you need to do is to install the tkinter package. Now universal precompiled packages such as ActivePython will not work, well at least it didn't work for me. I don't know if this problem occurs in other OSes but I know the solution for Linux: Install the Tk package from the terminal.
In Arch, Tk is available in the Arch repository. You don't need aur for this, just type on the terminal:
sudo pacman -S tk
If you are on another Linux distro such as Debian or a Debian based distro you will probably have to find a PPA repository online and in Debian based distros just type on the terminal:
sudo apt-get install tk
Which applies to all distros.
回答2:
I'm on Manjaro, use Gnome3 on Wayland. After installed tk
I got an error about Xorg. So I use Google, and found I need to install python-pygubu
from Visual editor for creating GUI in Python 3 tkinter.
And then another error like: Gtk-WARNING **: Unable to locate theme engine in module_path: "murrine". Also found a solution, to install gtk-engine-murrine
form that link.
来源:https://stackoverflow.com/questions/48504746/importerror-libtk8-6-so-cannot-open-shared-object-file-no-such-file-or-direct