AUTOMATIC1111 / stable-diffusion-webui

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

ERROR: Cannot activate python venv, aborting..., even when python3-venv is installed #1120

Closed picarica closed 2 years ago

picarica commented 2 years ago

Describe the bug after installing all dependencies i stil get error ERROR: Cannot activate python venv, aborting...

To Reproduce Steps to reproduce the behavior: 1.i just pasted bash <(wget -qO- https://raw.githubusercontent.com/AUTOMATIC1111/stable-diffusion-webui/master/webui.sh),

Expected behavior to work

Screenshots Screenshot from 2022-09-26 21-34-49

Desktop (please complete the following information):

Additional context i have Linux Mint 20.3 Cinnamon

telans commented 2 years ago

Does source venv/bin/activate output anything?

picarica commented 2 years ago

Does source venv/bin/activate output anything?

nope, its empty bash: venv/bin/activate: No such file or directory i am not sure why, it suses the command used in the documentation, even when cloning it results the same folder without the activate bin

telans commented 2 years ago

You should check that python3-venv or virtualenv is installed.

python3 -c 'import venv' should not return any errors

python3 -m venv venv/ should populate the directory

Have you set a custom value for python_cmd in webui-user.sh?

picarica commented 2 years ago

python3 -c 'import venv ran fine without errors python3 -m venv venv/ fixed it, thanks for your help

nosville22 commented 2 years ago

Same issue, except when running source venv/bin/activate it just spews the exact same error.

lizekui commented 2 years ago

Well, I met this bug too under my old machine Ubuntu 16.04, and use 2 hours to find solution....

the clue of this problem is 'ensurepip component is missing/disabled on Ubuntu' but ensurepip is invoked in python3 -m venv venv/

Because I found the when I type python3 -m venv venv/ error show:

Error: Command '['/home/whoami/stable-diffusion-webui/venv/bin/python3', '-Im', 'ensurepip', '--upgrade', '--default-pip']' returned non-zero exit status 1.

I run python3 -Im ensurepip --upgrade --default-pip shows:

python3: No module named ensurepi

Solution is simple:

/python3 -m venv venv/ --without-pip to generate 'activate' file in venv/bin folder

awwalm commented 2 years ago

For others still stuck, I noticed the venv included in Automatic1111's clone of SDUI won't work as expected if your local Python version is different from the version used in that venv (3.8).

After a lot of research:

[^1]: I encountered the dreaded ensurepip error ("the virtual environment was not created successfully because ensurepip is not available") while troubleshooting the OP, which led me to this Stackoverflow trail/answer

csk06 commented 1 year ago

@lizekui @awwalm

Hi,

I have followed both of your instructions, but still having the same error. Do you have any idea ?

Thanks

ThatCoffeeGuy commented 1 year ago

@lizekui @awwalm

Hi,

I have followed both of your instructions, but still having the same error. Do you have any idea ?

Thanks

You need to enter the stable-diffusion-webui folder, execute python3 -m venv venv/ then execute the bash script again.

cd stable-diffusion-webui
python3 -m venv venv/
cd ..
bash <(wget -qO- https://raw.githubusercontent.com/AUTOMATIC1111/stable-diffusion-webui/master/webui.sh)
Natotela commented 1 year ago

python3 -m venv venv/

Does it matter if I use python3 or python? I installed 3106, set webui-user with python_cmd="python" rather than python3, since 'python3' is not recognized. Still getting the same error when I run the sh in Git Bash (win10) sd-webui folder. not too sure why I needa cd.. out of it (then I get the python3 not found, hence I'm asking). 10x

BarneyChambers commented 1 year ago
python3 -c 'import venv'
sudo python3 -m venv venv/ 

I needed a sudo on there as well, for permission's sake

ZHH-start commented 1 year ago

I meat this problem too. 2023-02-20 11-11-21 的屏幕截图 and……I delete all venv folder.Both at my home folder and at this mother folder.then I run bash webui.sh

and it's work. 2023-02-20 11-13-37 的屏幕截图 2023-02-20 11-13-56 的屏幕截图

urrrrrr sorry its also have some problems.......just solve venv's problem yet.......

jasondu commented 1 year ago

go to /home/whoami/stable-diffusion-webui/, whoami is your current username. and rm -rf venv/, and run python3 -m venv venv/

tomtudu333 commented 1 year ago

In aws I used t2.xlarge instance and download was instant for some reason, otherwise it was not working in smaller instances.

ZHH-start commented 1 year ago

get it. I have solved it at 4.10, but thanks also. I remenber I delete the .venv at root directory to address it.Or I forget the truth....

Vic020 commented 1 year ago

it works for me.

  1. locate root of stable-diffusion-webui folder
  2. delete venv/ rm -rf venv
  3. rerun webui.sh ./webui.sh

it would re-create a new venv python, and it works fine.

HongchangNJ commented 1 year ago

You should check that python3-venv or virtualenv is installed.

python3 -c 'import venv' should not return any errors

python3 -m venv venv/ should populate the directory

Have you set a custom value for python_cmd in webui-user.sh?

it works

Cristtiano commented 1 year ago

Solved by "chown -R $USER:$USER /var/www/.../stable-diffusion-webui"

PeteInBrissie commented 1 year ago

python3 -m venv venv/

That fixed it for me. Thanks!

liuchengts commented 11 months ago
sudo apt update
cd stable-diffusion-webui
rm -rf venv
sudo apt install python3-venv
./webui.sh

solved my problem

qdhfsh commented 11 months ago
sudo apt install  python3-venv
python3 -m venv venv/
source venv/bin/activate

It works for me.

ilulillirillion commented 5 months ago

For others still stuck, I noticed the venv included in Automatic1111's clone of SDUI won't work as expected if your local Python version is different from the version used in that venv (3.8).

After a lot of research:

  • I installed the venv for python 3.8 despite running python 3.10 on Ubuntu 20.041: sudo apt-get install python3.8-venv
  • Followed @lizekui 's instructions.
  • Executed the bash script and it finally ran.

Footnotes

  1. I encountered the dreaded ensurepip error ("the virtual environment was not created successfully because ensurepip is not available") while troubleshooting the OP, which led me to this Stackoverflow trail/answer

This was it for me as well. Using pyenv, within the working directory, I simply

pyenv install 3.10
pyenv local 3.10
./webui.sh

Should probably be notated in the documentation, thank you for noticing this, helped a lot

mimoo commented 3 months ago

Screenshot 2024-08-01 at 6 47 26 PM

^ uncommenting that line in webui-user.sh did it for me.

(I had done pyenv install 3.10 && pyenv local 3.10 prior to that)

amanlai commented 3 months ago

Related Stack Overflow discussion.

raffaem commented 1 month ago

If you use pyenv, create a virtual environment and then export python_cmd to point to the Python of the virtual environment

E.g.

pyenv virtualenv 3.10 stable-diffusion-webui
pyenv local stable-diffusion-webui
export python_cmd="$HOME/.pyenv/versions/stable-diffusion-webui/bin/python3"
./webui.sh
JaxSparrows commented 3 weeks ago

Same problem when i run " python3 -c 'import venv' " ran fine without errors but when i run " python3 -m venv venv/ " it ran without error but it also doesn't do anything image_2024-10-22_000014338

When i try to Install Pyenv prereqs it outputs: 0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.

When i try to install pyenv it outputs: WARNING: Can not proceed with installation. Kindly remove the '/home/jax_sparrow/.pyenv' directory first.

When i try to install Python 3.10 it outputs: image_2024-10-22_000312454

OS: Window 11 Home

CyberT33N commented 3 weeks ago

In my case deleting the venv folder helped.

If not try to enable in webui-user.sh:

# python3 executable
python_cmd="python3"
luigiMinardi commented 3 days ago

had this problem cuz I was running python at version 3.12 as default, switched to 3.10.6 and it all worked fine.