Setup script fails on Arch Linux: ModuleNotFoundError: No module named 'pkg_resources'
This is what I get when trying to run the setup script on a current Arch linux:
> ~/opt/kohya_ss/kohya_ss -> ./setup.sh
Skipping git operations.
Arch Linux or Arch base detected.
Python TK found...
Switching to virtual Python environment.
Traceback (most recent call last):
File "/home/ben/opt/kohya_ss/kohya_ss/setup/setup_linux.py", line 3, in <module>
import setup_common
File "/home/ben/opt/kohya_ss/kohya_ss/setup/setup_common.py", line 8, in <module>
import pkg_resources
ModuleNotFoundError: No module named 'pkg_resources'
Exiting Python virtual environment.
Setup finished! Run ./gui.sh to start.
Please note if you'd like to expose your public server you need to run ./gui.sh --share
Any advice on what to do? Thank you!
Are you using python version higher than 3.10.9 but lower than 3.11.0 in the venv?
Hey,
I am not sure. How would I configure what python version is being used in the venv?
Default Python version on the system is 3.13.1 But I also installed 3.10.16-1 from here: https://aur.archlinux.org/packages?O=0&SeB=nd&K=python+3.10&outdated=&SB=p&SO=d&PP=50&submit=Go
I have this in /usr/bin:
[root@ben bin]# ls -la | grep python
-rwxr-xr-x 1 root root 5346 21. Nov 14:34 activate-global-python-argcomplete
-rwxr-xr-x 1 root root 14480 19. Dez 15:44 grpc_python_plugin
lrwxrwxrwx 1 root root 53 20. Nov 10:43 lirc-setup -> ../lib/python3.13/site-packages/lirc-setup/lirc-setup
lrwxrwxrwx 1 root root 7 4. Dez 19:05 python -> python3
lrwxrwxrwx 1 root root 10 4. Dez 19:05 python3 -> python3.13
-rwxr-xr-x 1 root root 14208 17. Jan 03:15 python3.10
-rwxr-xr-x 1 root root 3234 17. Jan 03:15 python3.10-config
-rwxr-xr-x 1 root root 14384 4. Dez 19:05 python3.13
-rwxr-xr-x 1 root root 3446 4. Dez 19:05 python3.13-config
lrwxrwxrwx 1 root root 17 4. Dez 19:05 python3-config -> python3.13-config
-rwxr-xr-x 1 root root 2604 21. Nov 14:34 python-argcomplete-check-easy-install-script
lrwxrwxrwx 1 root root 14 4. Dez 19:05 python-config -> python3-config
-rwxr-xr-x 1 root root 1992 21. Nov 14:34 register-python-argcomplete
Maybe setup.sh is not using 3.10 for the venv? How would I configure that? Sadly I have no idea how python works behind the curtains.
pkg_resources is part of python's setuptools package. Are you able to install through pip, specifically for python3.10 and not your system's python3.13?
Sorry I have no idea about the inner workings of python. I am lost here. Could you provide instructions on how to install the required packages? I have python-pip and python-env installed. Some tutorial suggested it. But I can't make it work.
I'm going to suggest using miniconda since it avoids having to compile from source packages.
Refer to the install instructions for Miniconda here but basically, this...
mkdir -p ~/miniconda3
wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh -O ~/miniconda3/miniconda.sh
bash ~/miniconda3/miniconda.sh -b -u -p ~/miniconda3
rm ~/miniconda3/miniconda.sh
Side note: The above commands will make a directory called miniconda3 in your home dir, which is where conda's python packages will reside. If you don't know what you're doing, do not remove/relocate miniconda3 since that may break the install.
Now set up conda environment with python 3.10
source ~/miniconda3/bin/activate
conda create -n py310 python=3.10.16
conda activate py310
And do the setup for kohya_ss as usual. I recommend deleting the existing venv if you have one present.
cd kohya_ss
rm -fr venv
./setup.sh
If that all works out, start the GUI.
./gui.sh
I believe there will be additional things to set up, but see if you can get the web GUI to run.
Thank you very much! I will try that out and report back.
This worked! I was able to reach the GUI. Did not have time to train yet. Thank you very much for your help. I guess this will help a lot of people on Arch!
I'd like to get it working without miniconda and I'm getting the same error. Any hint on how to do it?
(.venv) lucas@lucas-MS-7D98:~/Documents/kohya_ss$ python --version
Python 3.10.11
(.venv) lucas@lucas-MS-7D98:~/Documents/kohya_ss$ pip show setuptools
Name: setuptools
Version: 75.8.2
Summary: Easily download, build, install, upgrade, and uninstall Python packages
Home-page:
Author:
Author-email: Python Packaging Authority <[email protected]>
License:
Location: /home/lucas/Documents/kohya_ss/.venv/lib/python3.10/site-packages
Requires:
Required-by: lightning-utilities, wandb
(.venv) lucas@lucas-MS-7D98:~/Documents/kohya_ss$ ./setup.sh
Skipping git operations.
Ubuntu detected.
Python TK found...
Switching to virtual Python environment.
Traceback (most recent call last):
File "/home/lucas/Documents/kohya_ss/setup/setup_linux.py", line 3, in <module>
import setup_common
File "/home/lucas/Documents/kohya_ss/setup/setup_common.py", line 8, in <module>
import pkg_resources
ModuleNotFoundError: No module named 'pkg_resources'
Exiting Python virtual environment.
Setup finished! Run ./gui.sh to start.
Please note if you'd like to expose your public server you need to run ./gui.sh --share
EDIT - Solved it by deleting the virtual environment folders.
@wonder75 Did it work to train?
I have no problem running the gui without miniconda, I use pyenv instead.
Did it work with the the UV version or only legacy?
Do you use nvidia? If so, what cuda package did you use?