AUTOMATIC1111 / stable-diffusion-webui

Stable Diffusion web UI
GNU Affero General Public License v3.0
142.95k stars 26.95k forks source link

how to install the Install the dependencies in ubuntu #3498

Open lunar333 opened 2 years ago

lunar333 commented 2 years ago

Is there an existing issue for this?

What happened?

Install the dependencies:

Debian-based:

sudo apt install wget git python3 python3-venv

Red Hat-based:

sudo dnf install wget git python3

Arch-based:

sudo pacman -S wget git python3 while these does not work in ubuntu

Steps to reproduce the problem

  1. Go to ....
  2. Press ....
  3. ... install the dependencies

What should have happened?

there is not commad for ubuntu

Commit where the problem happens

bash

What platforms do you use to access UI ?

No response

What browsers do you use to access the UI ?

No response

Command Line Arguments

No response

Additional information, context and logs

No response

kiron111 commented 2 years ago

ubuntu is Debian-based

lunar333 commented 2 years ago

ubuntu is Debian-based

but I can not install the python3-venv. I have not the root, so the command "sudo apt install wget git python3 python3-venv" is not work for me , I simply use the command "conda install python3-venv" or "pip install python3-venv", both of them are not work

pravindahal commented 2 years ago

If you don't have root access, you will not be able to install python3-venv... but maybe it's already installed on your computer. Can you try to run the install script and if it doesn't work, could you post the output of the command here?

lunar333 commented 2 years ago

If you don't have root access, you will not be able to install python3-venv... but maybe it's already installed on your computer. Can you try to run the install script and if it doesn't work, could you post the output of the command here?

Install script for stable-diffusion + Web UI Tested on Debian 11 (Bullseye) ################################################################

################################################################ Running on zhh user ################################################################

################################################################ ERROR: python3-venv is not installed, aborting... ################################################################

pravindahal commented 2 years ago

Try this:

  1. Save the following file as webui.sh
#!/bin/bash
#################################################
# Please do not make any changes to this file,  #
# change the variables in webui-user.sh instead #
#################################################
# Read variables from webui-user.sh
# shellcheck source=/dev/null
if [[ -f webui-user.sh ]]
then
    source ./webui-user.sh
fi

# Set defaults
# Install directory without trailing slash
if [[ -z "${install_dir}" ]]
then
    install_dir="/home/$(whoami)"
fi

# Name of the subdirectory (defaults to stable-diffusion-webui)
if [[ -z "${clone_dir}" ]]
then
    clone_dir="stable-diffusion-webui"
fi

# python3 executable
if [[ -z "${python_cmd}" ]]
then
    python_cmd="python3"
fi

# git executable
if [[ -z "${GIT}" ]]
then
    export GIT="git"
fi

# python3 venv without trailing slash (defaults to ${install_dir}/${clone_dir}/venv)
if [[ -z "${venv_dir}" ]]
then
    venv_dir="venv"
fi

if [[ -z "${LAUNCH_SCRIPT}" ]]
then
    LAUNCH_SCRIPT="launch.py"
fi

# Disable sentry logging
export ERROR_REPORTING=FALSE

# Do not reinstall existing pip packages on Debian/Ubuntu
export PIP_IGNORE_INSTALLED=0

# Pretty print
delimiter="################################################################"

printf "\n%s\n" "${delimiter}"
printf "\e[1m\e[32mInstall script for stable-diffusion + Web UI\n"
printf "\e[1m\e[34mTested on Debian 11 (Bullseye)\e[0m"
printf "\n%s\n" "${delimiter}"

# Do not run as root
if [[ $(id -u) -eq 0 ]]
then
    printf "\n%s\n" "${delimiter}"
    printf "\e[1m\e[31mERROR: This script must not be launched as root, aborting...\e[0m"
    printf "\n%s\n" "${delimiter}"
    exit 1
else
    printf "\n%s\n" "${delimiter}"
    printf "Running on \e[1m\e[32m%s\e[0m user" "$(whoami)"
    printf "\n%s\n" "${delimiter}"
fi

if [[ -d .git ]]
then
    printf "\n%s\n" "${delimiter}"
    printf "Repo already cloned, using it as install directory"
    printf "\n%s\n" "${delimiter}"
    install_dir="${PWD}/../"
    clone_dir="${PWD##*/}"
fi

# Check prerequisites
for preq in "${GIT}" "${python_cmd}"
do
    if ! hash "${preq}" &>/dev/null
    then
        printf "\n%s\n" "${delimiter}"
        printf "\e[1m\e[31mERROR: %s is not installed, aborting...\e[0m" "${preq}"
        printf "\n%s\n" "${delimiter}"
        exit 1
    fi
done

#if ! "${python_cmd}" -c "import venv" &>/dev/null
#then
#    printf "\n%s\n" "${delimiter}"
#    printf "\e[1m\e[31mERROR: python3-venv is not installed, aborting...\e[0m"
#    printf "\n%s\n" "${delimiter}"
#    exit 1
#fi

printf "\n%s\n" "${delimiter}"
printf "Clone or update stable-diffusion-webui"
printf "\n%s\n" "${delimiter}"
cd "${install_dir}"/ || { printf "\e[1m\e[31mERROR: Can't cd to %s/, aborting...\e[0m" "${install_dir}"; exit 1; }
if [[ -d "${clone_dir}" ]]
then
    cd "${clone_dir}"/ || { printf "\e[1m\e[31mERROR: Can't cd to %s/%s/, aborting...\e[0m" "${install_dir}" "${clone_dir}"; exit 1; }
    "${GIT}" pull
else
    "${GIT}" clone https://github.com/AUTOMATIC1111/stable-diffusion-webui.git "${clone_dir}"
    cd "${clone_dir}"/ || { printf "\e[1m\e[31mERROR: Can't cd to %s/%s/, aborting...\e[0m" "${install_dir}" "${clone_dir}"; exit 1; }
fi

printf "\n%s\n" "${delimiter}"
printf "Create and activate python venv"
printf "\n%s\n" "${delimiter}"
cd "${install_dir}"/"${clone_dir}"/ || { printf "\e[1m\e[31mERROR: Can't cd to %s/%s/, aborting...\e[0m" "${install_dir}" "${clone_dir}"; exit 1; }
if [[ ! -d "${venv_dir}" ]]
then
    "${python_cmd}" -m virtualenv "${venv_dir}"
    first_launch=1
fi
# shellcheck source=/dev/null
if [[ -f "${venv_dir}"/bin/activate ]]
then
    source "${venv_dir}"/bin/activate
else
    printf "\n%s\n" "${delimiter}"
    printf "\e[1m\e[31mERROR: Cannot activate python venv, aborting...\e[0m"
    printf "\n%s\n" "${delimiter}"
    exit 1
fi

printf "\n%s\n" "${delimiter}"
printf "Launching launch.py..."
printf "\n%s\n" "${delimiter}"
"${python_cmd}" "${LAUNCH_SCRIPT}" "$@"
  1. Run the following commands:
pip install virtualenv --user
chmod +x webui.sh
./webui.sh

Let me know if you encounter any errors.

lunar333 commented 2 years ago

Try this:

  1. Save the following file as webui.sh
#!/bin/bash
#################################################
# Please do not make any changes to this file,  #
# change the variables in webui-user.sh instead #
#################################################
# Read variables from webui-user.sh
# shellcheck source=/dev/null
if [[ -f webui-user.sh ]]
then
    source ./webui-user.sh
fi

# Set defaults
# Install directory without trailing slash
if [[ -z "${install_dir}" ]]
then
    install_dir="/home/$(whoami)"
fi

# Name of the subdirectory (defaults to stable-diffusion-webui)
if [[ -z "${clone_dir}" ]]
then
    clone_dir="stable-diffusion-webui"
fi

# python3 executable
if [[ -z "${python_cmd}" ]]
then
    python_cmd="python3"
fi

# git executable
if [[ -z "${GIT}" ]]
then
    export GIT="git"
fi

# python3 venv without trailing slash (defaults to ${install_dir}/${clone_dir}/venv)
if [[ -z "${venv_dir}" ]]
then
    venv_dir="venv"
fi

if [[ -z "${LAUNCH_SCRIPT}" ]]
then
    LAUNCH_SCRIPT="launch.py"
fi

# Disable sentry logging
export ERROR_REPORTING=FALSE

# Do not reinstall existing pip packages on Debian/Ubuntu
export PIP_IGNORE_INSTALLED=0

# Pretty print
delimiter="################################################################"

printf "\n%s\n" "${delimiter}"
printf "\e[1m\e[32mInstall script for stable-diffusion + Web UI\n"
printf "\e[1m\e[34mTested on Debian 11 (Bullseye)\e[0m"
printf "\n%s\n" "${delimiter}"

# Do not run as root
if [[ $(id -u) -eq 0 ]]
then
    printf "\n%s\n" "${delimiter}"
    printf "\e[1m\e[31mERROR: This script must not be launched as root, aborting...\e[0m"
    printf "\n%s\n" "${delimiter}"
    exit 1
else
    printf "\n%s\n" "${delimiter}"
    printf "Running on \e[1m\e[32m%s\e[0m user" "$(whoami)"
    printf "\n%s\n" "${delimiter}"
fi

if [[ -d .git ]]
then
    printf "\n%s\n" "${delimiter}"
    printf "Repo already cloned, using it as install directory"
    printf "\n%s\n" "${delimiter}"
    install_dir="${PWD}/../"
    clone_dir="${PWD##*/}"
fi

# Check prerequisites
for preq in "${GIT}" "${python_cmd}"
do
    if ! hash "${preq}" &>/dev/null
    then
        printf "\n%s\n" "${delimiter}"
        printf "\e[1m\e[31mERROR: %s is not installed, aborting...\e[0m" "${preq}"
        printf "\n%s\n" "${delimiter}"
        exit 1
    fi
done

#if ! "${python_cmd}" -c "import venv" &>/dev/null
#then
#    printf "\n%s\n" "${delimiter}"
#    printf "\e[1m\e[31mERROR: python3-venv is not installed, aborting...\e[0m"
#    printf "\n%s\n" "${delimiter}"
#    exit 1
#fi

printf "\n%s\n" "${delimiter}"
printf "Clone or update stable-diffusion-webui"
printf "\n%s\n" "${delimiter}"
cd "${install_dir}"/ || { printf "\e[1m\e[31mERROR: Can't cd to %s/, aborting...\e[0m" "${install_dir}"; exit 1; }
if [[ -d "${clone_dir}" ]]
then
    cd "${clone_dir}"/ || { printf "\e[1m\e[31mERROR: Can't cd to %s/%s/, aborting...\e[0m" "${install_dir}" "${clone_dir}"; exit 1; }
    "${GIT}" pull
else
    "${GIT}" clone https://github.com/AUTOMATIC1111/stable-diffusion-webui.git "${clone_dir}"
    cd "${clone_dir}"/ || { printf "\e[1m\e[31mERROR: Can't cd to %s/%s/, aborting...\e[0m" "${install_dir}" "${clone_dir}"; exit 1; }
fi

printf "\n%s\n" "${delimiter}"
printf "Create and activate python venv"
printf "\n%s\n" "${delimiter}"
cd "${install_dir}"/"${clone_dir}"/ || { printf "\e[1m\e[31mERROR: Can't cd to %s/%s/, aborting...\e[0m" "${install_dir}" "${clone_dir}"; exit 1; }
if [[ ! -d "${venv_dir}" ]]
then
    "${python_cmd}" -m virtualenv "${venv_dir}"
    first_launch=1
fi
# shellcheck source=/dev/null
if [[ -f "${venv_dir}"/bin/activate ]]
then
    source "${venv_dir}"/bin/activate
else
    printf "\n%s\n" "${delimiter}"
    printf "\e[1m\e[31mERROR: Cannot activate python venv, aborting...\e[0m"
    printf "\n%s\n" "${delimiter}"
    exit 1
fi

printf "\n%s\n" "${delimiter}"
printf "Launching launch.py..."
printf "\n%s\n" "${delimiter}"
"${python_cmd}" "${LAUNCH_SCRIPT}" "$@"
  1. Run the following commands:
pip install virtualenv --user
chmod +x webui.sh
./webui.sh

Let me know if you encounter any errors.

I have followed your suggestion,and there are some errors:

################################################################ Install script for stable-diffusion + Web UI Tested on Debian 11 (Bullseye) ################################################################

################################################################ Running on zhh user ################################################################

################################################################ Clone or update stable-diffusion-webui ################################################################ fatal: not a git repository (or any parent up to mount point /) Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).

################################################################ Create and activate python venv ################################################################ ./webui.sh: line 121: cd: /disk2/zhh/stable-diffusion-webui/install_dir//disk2/zhh/stable-diffusion-webui/: No such file or directory

pravindahal commented 2 years ago

It seems like you have downloaded and unzipped the git repo. Please remove it and retry running the above script.

lunar333 commented 2 years ago

It seems like you have downloaded and unzipped the git repo. Please remove it and retry running the above script.

remove all the file, but except the webui.sh and webui-user.sh, then running the webui.sh, is that right?

lunar333 commented 2 years ago

It seems like you have downloaded and unzipped the git repo. Please remove it and retry running the above script.

################################################################ Install script for stable-diffusion + Web UI Tested on Debian 11 (Bullseye) ################################################################

################################################################ Running on zhh user ################################################################

################################################################ Repo already cloned, using it as install directory ################################################################

################################################################ Clone or update stable-diffusion-webui ################################################################ Already up to date.

################################################################ Create and activate python venv ################################################################ /disk2/zhh/kaldi/tools/python/python: No module named virtualenv

################################################################ ERROR: Cannot activate python venv, aborting... ################################################################

I have removed the files, the running your script again ,and is turns out the errows

pravindahal commented 2 years ago

It seems like you forgot to run this first:

pip install virtualenv --user
lunar333 commented 2 years ago

It seems like you forgot to run this first:

pip install virtualenv --user

I run the command: pip install virtualenv --user and it turns out that Requirement already satisfied: virtualenv in /disk2/zhh/miniconda3/envs/torch/lib/python3.9/site-packages (20.16.5) Requirement already satisfied: distlib<1,>=0.3.5 in /disk2/zhh/miniconda3/envs/torch/lib/python3.9/site-packages (from virtualenv) (0.3.6) Requirement already satisfied: filelock<4,>=3.4.1 in /disk2/zhh/miniconda3/envs/torch/lib/python3.9/site-packages (from virtualenv) (3.8.0) Requirement already satisfied: platformdirs<3,>=2.4 in /disk2/zhh/miniconda3/envs/torch/lib/python3.9/site-packages (from virtualenv) (2.5.2)

then I run ./webui.sh it turns out the errows : ################################################################ Install script for stable-diffusion + Web UI Tested on Debian 11 (Bullseye) ################################################################

################################################################ Running on zhh user ################################################################

################################################################ Repo already cloned, using it as install directory ################################################################

################################################################ Clone or update stable-diffusion-webui ################################################################ Already up to date.

################################################################ Create and activate python venv ################################################################ /disk2/zhh/kaldi/tools/python/python: No module named virtualenv

################################################################ ERROR: Cannot activate python venv, aborting... ################################################################

birgador commented 2 years ago

Check that there is a folder named "venv" already. If it is, delete it and try again.

bonsaipanda commented 2 years ago

I ran into this issue on Pop!_OS with python 3.10.

It stems from not being able to install venv and I have no idea how to fix that, other than somehow install an older python next to 3.10 >> E: Package 'python3.10-venv' has no installation candidate

Natotela commented 1 year ago

Check that there is a folder named "venv" already. If it is, delete it and try again.

Tried deleting it, ran webui.sh - it recreated the folder without any bin sub-dir GIT Bash, win10, python3106, using python cmd rather than python3 which is not found

459737087 commented 1 year ago

Did you solve it @lunar333

ZhuJD-China commented 1 year ago

Check that there is a folder named "venv" already. If it is, delete it and try again.

Tried deleting it, ran webui.sh - it recreated the folder without any bin sub-dir GIT Bash, win10, python3106, using python cmd rather than python3 which is not found

delete it and try again helpfuly

ritzcarltn commented 10 months ago

Check that there is a folder named "venv" already. If it is, delete it and try again.

Big thanks