[Bug]: Python does not seem to work the way it should.
Is there an existing issue for this?
- [ ] I have searched the existing issues and checked the recent builds/commits
What happened?
Something seems to be messed up with Python. I did check the environment variables, and made sure that both PATH and PYTHONPATH were being directed to the current version of Python (C:\Python\python.exe). While, normally, I wouldn't be using a custom path with Python, after having so much trouble with it of late, I figured it would be easier to start fresh, install a new version of Python and Anaconda, and start a new version of Stable Diffusion. Sadly that didn't work, and every time I run webui-user.bat, I get the following message.
venv "S:\AITemp\venv\Scripts\Python.exe"
Python 3.10.6 (tags/v3.10.6:9c7b4bd, Aug 1 2022, 21:53:49) [MSC v.1932 64 bit (AMD64)]
Commit hash: 5f4fa942b8ec3ed3b15a352903489d6f9e6eb46e
Installing torch and torchvision
Traceback (most recent call last):
File "S:\AITemp\launch.py", line 294, in <module>
prepare_environment()
File "S:\AITemp\launch.py", line 206, in prepare_environment
run(f'"{python}" -m {torch_command}', "Installing torch and torchvision", "Couldn't install torch")
File "S:\AITemp\launch.py", line 49, in run
raise RuntimeError(message)
RuntimeError: Couldn't install torch.
Command: "S:\AITemp\venv\Scripts\python.exe" -m pip install torch==1.12.1+cu113 torchvision==0.13.1+cu113 --extra-index-url https://download.pytorch.org/whl/cu113
Error code: 1
stdout: <empty>
stderr: S:\AITemp\venv\Scripts\python.exe: No module named pip
I did run Python, both at S:\AITemp, and S:\AITemp\venv\Scripts, and tired to install/update pip by using get-pip.py, and while it did run successfully, it still gave me the same error. Just so we're on the same page the guide that I am following is from here:
https://mrdeepfakes.com/forums/threads/guide-using-stable-diffusion-to-generate-custom-nsfw-images.10289/
Also, for some weird reason, Pytorch will install when using Anaconda, but when I use the Python command prompt, I get the following message:
Python 3.10.6 (tags/v3.10.6:9c7b4bd, Aug 1 2022, 21:53:49) [MSC v.1932 64 bit (AMD64)] on win32
>>> pip3 install torch torchvision torchaudio --extra-index-url https://download.pytorch.org/whl/cu116
File "<stdin>", line 1
pip3 install torch torchvision torchaudio --extra-index-url https://download.pytorch.org/whl/cu116
^^^^^^^
SyntaxError: invalid syntax
>>>
Steps to reproduce the problem
- Go to webui-user.bat
- Press enter
- Shit bricks
What should have happened?
Everything loading/launching/updating and then Stable Diffusion being ran.
Commit where the problem happens
5f4fa942b8ec3ed3b15a352903489d6f9e6eb46e
What platforms do you use to access UI ?
Windows
What browsers do you use to access the UI ?
Microsoft Edge
Command Line Arguments
No response
Additional information, context and logs
No response
I have no assurances, but imho you either follow a standard guide for standalone python, or this Seems like something is wrong when venv being created from conda python. I just spent a half a day digging through all issues here, and every time something is wrong there's conda around. Judging from your python path, it is standalone. Why do you even need Anaconda then?
Why do you even need Anaconda then?
Because I have no idea what I'm doing and am forced to rely on those who know more about it than I do. I'm not kidding...I am waaaaay out of my element here. Doesn't mean I'm not prepared to learn...if I can program my macro keyboard in LUA then I can learn at least learn the basics so far as what pertains to what I am trying to do. That said every instance that I've read before says to install Anaconda for some reason, which yes, as you said earlier, struck me as strange since Python seems to be standalone to whatever folder Stable Diffusion is installed in.
I did try following the guide you referenced, and got the same error message as always, so doing it through Anaconda didn't produce any changed results. As a result I uninstalled Anaconda and Python to see what would happen, so that the standalone instances of Python were all that was in use, and I got the same error. I don't know dude...if there is no external version of Python to use, and it's all standalone, it sounds a lot like something is seriously wrong here, and since I haven't edited anything, I'm kind of at a loss in terms of what to do to fix the problem...though I am thinking about doing a Windows install as a last resort...yes it's that bad.
Get rid of conda. It is very annoying and break all thing.
@aliencaocao
I got rid of both Anaconda and Python so that only the standalone version of Python within the root Stable Diffusion and Venv\Scripts would be the ones running, and I still got the exact same error. Also, yes, I did change the environment variables ahead of time so that it would point directly to only those two folders...same results.
You are not supposed to get rid of python...the one in venv is incomplete. It is missing a lot of libraries, it depends on the main installation to work
Clear everything, install standalone python 3.10.6, make sure git and python are callable from anywhere in cmd (i.e., they're in PATH variable)
Then shove in the model checkpoint and run. Nothing else is required.
The way it works, when SD launches for the first time it creates virtual environment for itself, that still uses base python, but can evolve separatly without ruining your base.
What i find most curious is how you overlooked the basic, simplest guide and turned to anaconda? I messed around with it too, but that's because i already had it installed, but a new user not familiar with stuff should follow readme guide with literally 6 steps, in which step 5 is heaviliy outdated and not required any more, so 5 steps total.

Anaconda is literally bloatware. Just follow the instructions and get python 3.10.6 instead and let webui install the packages on first launch
I tried what everyone suggested and...it worked? Tried to copy the working files into WaifuDiffusion, and nothing worked. Thought about it for a moment, and realized it was probably because there was still some stuff left over from Anaconda, which is why there was such a conflict. Also, just a heads up, but you may have to manually add PYTHON to your environment variables, since what is listed isn't PATH but PYTHON for the webui.bat file. For some reason it wasn't even listed in mine, so I manually added it myself, but I've no idea if it really accomplished anything or not. Still, it works, and it's not likely something is going to go wrong (fingers crossed), so if it's not broke don't fix it.
That said I'm going to remove it later on just to see what happens to sate my own curiosity because I got more time than I should on my hands. :P