lllyasviel / stable-diffusion-webui-forge

GNU Affero General Public License v3.0
8.05k stars 787 forks source link

[Bug]: cannot install: "This program is tested with 3.10.6 Python, but you have 3.12.1." #126

Closed rafstahelin closed 8 months ago

rafstahelin commented 8 months ago

Checklist

What happened?

cannot install. What is the workaround?

Steps to reproduce the problem

Install with Python 3.12

What should have happened?

Installation

What browsers do you use to access the UI ?

No response

Sysinfo

Cannot install

Console logs

venv "E:\stable-diffusion-webui-forge\venv\Scripts\Python.exe"
==============================================================================================================
INCOMPATIBLE PYTHON VERSION

This program is tested with 3.10.6 Python, but you have 3.12.1.
If you encounter an error with "RuntimeError: Couldn't install torch." message,
or any other error regarding unsuccessful package (library) installation,
please downgrade (or upgrade) to the latest version of 3.10 Python
and delete current Python and "venv" folder in WebUI's directory.

You can download 3.10 Python from here: https://www.python.org/downloads/release/python-3106/

Alternatively, use a binary release of WebUI: https://github.com/AUTOMATIC1111/stable-diffusion-webui/releases

Use --skip-python-version-check to suppress this warning.
==============================================================================================================
Python 3.12.1 (tags/v3.12.1:2305ca5, Dec  7 2023, 22:03:25) [MSC v.1937 64 bit (AMD64)]
Version: f0.0.10-latest-76-g291ec743
Commit hash: 291ec743b603fdcd9c58e60dc5ed3d866c53bc4c
Installing torch and torchvision
Looking in indexes: https://pypi.org/simple, https://download.pytorch.org/whl/cu121
ERROR: Could not find a version that satisfies the requirement torch==2.1.2 (from versions: 2.2.0, 2.2.0+cu121)
ERROR: No matching distribution found for torch==2.1.2

[notice] A new release of pip is available: 23.2.1 -> 24.0
[notice] To update, run: E:\stable-diffusion-webui-forge\venv\Scripts\python.exe -m pip install --upgrade pip
Traceback (most recent call last):
  File "E:\stable-diffusion-webui-forge\launch.py", line 48, in <module>
    main()
  File "E:\stable-diffusion-webui-forge\launch.py", line 39, in main
    prepare_environment()
  File "E:\stable-diffusion-webui-forge\modules\launch_utils.py", line 423, in prepare_environment
    run(f'"{python}" -m {torch_command}', "Installing torch and torchvision", "Couldn't install torch", live=True)
  File "E:\stable-diffusion-webui-forge\modules\launch_utils.py", line 122, in run
    raise RuntimeError("\n".join(error_bits))
RuntimeError: Couldn't install torch.
Command: "E:\stable-diffusion-webui-forge\venv\Scripts\python.exe" -m pip install torch==2.1.2 torchvision==0.16.2 --extra-index-url https://download.pytorch.org/whl/cu121
Error code: 1
Press any key to continue . . .

Additional information

No response

huchenlei commented 8 months ago

A1111 requires python 3.10. We have no plan to change that.

rafstahelin commented 8 months ago

Ok but auto1111, focus, comfyui, and kohya all work fine as it is with 3.12Can I downgrade to 3.10 and just rebuild all the  venv’s?Best, Raf On 8 Feb 2024, at 16:13, Chenlei Hu @.***> wrote: A1111 requires python 3.10. We have no plan to change that.

—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you authored the thread.Message ID: @.***>

huchenlei commented 8 months ago

If you have an existing venv, you can reference it by setting it here: https://github.com/lllyasviel/stable-diffusion-webui-forge/blob/291ec743b603fdcd9c58e60dc5ed3d866c53bc4c/webui-user.bat#L5

GOLDENLULUZ commented 7 months ago

If you have an existing venv, you can reference it by setting it here:

https://github.com/lllyasviel/stable-diffusion-webui-forge/blob/291ec743b603fdcd9c58e60dc5ed3d866c53bc4c/webui-user.bat#L5

Hello. will you kindly provide a step-by-step instruction on how to fix the problem for us? I know nothing about python and venv and really want to use forge. Thank you very much.

cdobrich commented 4 months ago

So I was able to get Forge to work on Python 3.11, in Ubuntu 24.04. Here are the steps I followed:

  1. Add the PPA for extra Python libraries to the Ubuntu package manager. For more detailed instructions see here: The commands are basically this:

    sudo add-apt-repository ppa:deadsnakes/ppa
    sudo apt update
  2. Install a Stable Diffusion compatible python version AND the python venv module package.

    sudo apt install python3.11 python3.11-venv
  3. (For this next step, I recreated the whole 'venv' folder, just to be sure of avoiding conflicts. This may not be strictly necessary.)

    In the folder where you installed / extracted / downloaded your Stable Diffusion Forge), rename any existing 'venv' folder to something else. I suggest 'venv.old'.

  4. Create a new 'venv' folder with this command:

    python3.11 -m venv "venv"
  5. In the folder where you installed / extracted / downloaded your Stable Diffusion Forge), edit the file 'webui-user.sh'.

  6. Change the section:

    # python3 executable
    #python_cmd="python3"

    to be:

    # python3 executable
    python_cmd="python3.11"
  1. Optional: Make any other custom changes you want to the 'webui-user.sh' file, such has the COMMANDLINE_ARGS parameters.
  2. Now start the webui for Stable Diffusion as normal. If you followed the steps to create a fresh 'venv' folder, this will trigger a full reinstall and download any necessary packages, and compile them.

That should fix your Stable Diffusion for Ubuntu 24.04!

Note: I was able to do this with Python 3.10 on Automatic1111 also. Same solution with adjusted version numbers for that.

greedy-buyer commented 3 months ago

There is another way I found, which helped me on Ubuntu 24.04, with pyenv:

  1. sudo apt install -y make build-essential libssl-dev zlib1g-dev libbz2-dev libreadline-dev libsqlite3-dev wget curl llvm libncurses5-dev libncursesw5-dev xz-utils tk-dev libffi-dev liblzma-dev python3-openssl git
  2. curl https://pyenv.run | bash
  3. Add the following lines to your .bashrc (nano ~/.bashrc):
    export PATH="$HOME/.pyenv/bin:$PATH"
    eval "$(pyenv init --path)"
    eval "$(pyenv init -)"
    eval "$(pyenv virtualenv-init -)"
  4. exec "$SHELL"
  5. pyenv install 3.10.6 (which stable diffusion webui forge needs)
  6. cd /to/your/stable/diffusion/folder
  7. pyenv local 3.10.6

Then you can test it with: python3 --version and it should show you 3.10.6, so inside of that directory it will use this version, while your global python 3.12.1 (or whatever version) which Ubuntu system uses will not change. just ./webui.sh