LostRuins / koboldcpp

A simple one-file way to run various GGML and GGUF models with a KoboldAI UI
https://github.com/lostruins/koboldcpp
GNU Affero General Public License v3.0
4.42k stars 322 forks source link

customtkinter error: Failed to use new GUI. Reason: No module named '_tkinter' #418

Open mapleroyal opened 10 months ago

mapleroyal commented 10 months ago

Prerequisites

Please answer the following questions for yourself before submitting an issue.

Expected Behavior

NOTE:

$ git clone https://github.com/LostRuins/koboldcpp
$ cd koboldcpp
$ pyenv local 3.11.5
$ python -m venv koboldcpp
$ source koboldcpp/bin/activate
$ pip install customtkinter
$ make
$ ./koboldcpp.py

should launch the app

Current Behavior

Instead, I get this error:

***
Welcome to KoboldCpp - Version 1.42.1
For command line arguments, please refer to --help
***
Failed to use new GUI. Reason: No module named '_tkinter'
Make sure customtkinter is installed!!!
Attempting to use old GUI...
File selection GUI unsupported. Please check command line: script.py --help
Reason for no GUI: No module named '_tkinter'
$ pip list
Package    Version
---------- -------
pip        23.2.1
setuptools 65.5.0

wtf

$ pip install customtkinter
Collecting customtkinter
  Obtaining dependency information for customtkinter from https://files.pythonhosted.org/packages/82/23/00394404c38db474d31471e618abbbc0034483c0d4178ba6328647da1a32/customtkinter-5.2.0-py3-none-any.whl.metadata
  Using cached customtkinter-5.2.0-py3-none-any.whl.metadata (652 bytes)
Collecting darkdetect (from customtkinter)
  Using cached darkdetect-0.8.0-py3-none-any.whl (9.0 kB)
Using cached customtkinter-5.2.0-py3-none-any.whl (295 kB)
Installing collected packages: darkdetect, customtkinter
Successfully installed customtkinter-5.2.0 darkdetect-0.8.0

$ pip list
Package       Version
------------- -------
customtkinter 5.2.0
darkdetect    0.8.0
pip           23.2.1
setuptools    65.5.0

$ ./koboldcpp.py
***
Welcome to KoboldCpp - Version 1.42.1
For command line arguments, please refer to --help
***
Failed to use new GUI. Reason: No module named '_tkinter'
Make sure customtkinter is installed!!!
Attempting to use old GUI...
File selection GUI unsupported. Please check command line: script.py --help
Reason for no GUI: No module named '_tkinter'

Environment and Context

M2 Max on current stable up to date macOS 13.5.1 Ventura. Python 3.11.5 Make 3.81

$ python3 --version
$ make --version
$ g++ --version
LostRuins commented 10 months ago

customtkinter requires tkinter to be installed, which is selected during your original python setup. That will be needed for the GUI to work.

mapleroyal commented 10 months ago

Because I'm using a custom environment (pyenv and a standard python venv, so that my global system configuration isn't disturbed), I needed to make sure that the python I installed with pyenv included tkinter. Here's the command that worked for me:

env PYTHON_CONFIGURE_OPTS="--with-tcltk-includes='-I/usr/local/opt/tcl-tk/include' --with-tcltk-libs='-L/usr/local/opt/tcl-tk/lib -ltcl8.6 -ltk8.6'" pyenv install 3.11.5

However, this is on a Mac so the goal is to use the GPU, but it's not using the GPU and it's not clear how to force it to use the GPU. Running ./koboldcpp.py and selecting the "Use No Blas" does not cause the app to use the GPU. Setting Threads to anything up to 12 increases CPU usage. The readme suggests running ./koboldcpp.py --noblas (I think these are old instructions, but I tried it nonetheless) and it also does not use the GPU.

mansueli commented 2 months ago

Hey @mapleroyal, seems like you managed to get it working. Can you share how you installed tkinter?

E.g the full steps that you managed to run to get it working on macos?

e.g

$ #Install tkinter somehow?! 
$ git clone https://github.com/LostRuins/koboldcpp
$ cd koboldcpp
$ env PYTHON_CONFIGURE_OPTS="--with-tcltk-includes='-I/usr/local/opt/tcl-tk/include' --with-tcltk-libs='-L/usr/local/opt/tcl-tk/lib -ltcl8.6 -ltk8.6'" pyenv install 3.11.5
$ python -m venv koboldcpp
$ source koboldcpp/bin/activate
$ pip install customtkinter
$ make
$ ./koboldcpp.py

I wasn't able to install tkinter following this: https://www.pythonguis.com/installation/install-tkinter-mac/

(kobold) me@madmac koboldcpp % brew install tkinter
==> Downloading https://formulae.brew.sh/api/formula.jws.json
############################################################################################################################################################################################################################################ 100.0%
==> Downloading https://formulae.brew.sh/api/cask.jws.json
############################################################################################################################################################################################################################################ 100.0%
Warning: No available formula with the name "tkinter".
==> Searching for similarly named formulae and casks...
==> Casks
tint

To install tint, run:
  brew install --cask tint
(kobold) me@madmac koboldcpp % 
mapleroyal commented 2 months ago

Hey @mapleroyal, seems like you managed to get it working. Can you share how you installed tkinter?

E.g the full steps that you managed to run to get it working on macos?

e.g


$ #Install tkinter somehow?! 

$ git clone https://github.com/LostRuins/koboldcpp

$ cd koboldcpp

$ env PYTHON_CONFIGURE_OPTS="--with-tcltk-includes='-I/usr/local/opt/tcl-tk/include' --with-tcltk-libs='-L/usr/local/opt/tcl-tk/lib -ltcl8.6 -ltk8.6'" pyenv install 3.11.5

$ python -m venv koboldcpp

$ source koboldcpp/bin/activate

$ pip install customtkinter

$ make

$ ./koboldcpp.py

I wasn't able to install tkinter following this:

https://www.pythonguis.com/installation/install-tkinter-mac/


(kobold) me@madmac koboldcpp % brew install tkinter

==> Downloading https://formulae.brew.sh/api/formula.jws.json

############################################################################################################################################################################################################################################ 100.0%

==> Downloading https://formulae.brew.sh/api/cask.jws.json

############################################################################################################################################################################################################################################ 100.0%

Warning: No available formula with the name "tkinter".

==> Searching for similarly named formulae and casks...

==> Casks

tint

To install tint, run:

  brew install --cask tint

(kobold) me@madmac koboldcpp % 

Sorry it was a long time ago and I don't remember. Usually I post when I find a solution to something so I assume my last post may have hinted at it, or else I gave up.

At the least, you need to make sure the version of Python that pyenv uses has the right stuff available, per my last post.