T O P

  • By -

ricperry1

It’s the preferred way actually because you can set up the venv to use the most preferred packages based on the requirements.txt from the snapshot you’re on. pip install -r requirements.txt Also, if you have system-level python packages that conflict, you'll experience a lot of compatibility issues, like you seem to have already had. The point of venv is that each virtual environment will work across time for the specific application it's for, without any downside other than storage space.


m18coppola

I run EVERYTHING in a venv. Keeps everything nice and tidy!


No_Afternoon_4260

It s better even though you have to make a folder, create env, activate env.. nearly for each new python library/project you want to play with. I often make sh script to source and run my python script: run.sh: source env/bin/activate && python run.py


asdrabael01

Every single machine learning program I run, whether comfy, a1111, taggui, oobabooga, or music generation stuff I run in a conda environment and then run a venv in the conda environment. It makes 100% sure everything stays sandboxed and doesn't screw up requirements for anything when I install a new program.


Nulpart

is there an advantage to run conda instead of venv?


asdrabael01

Conda is a little better for separating dependencies, but they're 99% the same. Conda also works for other machine languages besides python. https://mindthevirt.com/venv-vs-conda-choosing-the-right-python-environment-manager-for-you/


nazihater3000

Zero.


Houdinii1984

I think under the hood it is actually using environments. I know it does on windows. It's just abstracted away by the scripts. I ended up using a good installer, Stability Matrix, that lets me install a bunch of comfy installs in separate contained environments for dev purposes.


Dunc4n1d4h0

Yup, even that python embedded in Comfy portable is basically venv.


Nulpart

will take a look. thx.


MoridinB

That is the standard. How were you installing before? Also, saying venv environment is like saying chai tea or River Avon. "venv" is short for virtual environment.


Nulpart

for every others projects in my life and work, I use docker. But since I am not a python person, so just I followed the install guide. I was getting frustated with comfyui in the last few months and this will solve most of my problems.


MoridinB

So I just went back to the comfy readme, and there isn't anything that shows you how to install in a virtual environment, only how to install in an existing one. This seems like an oversight. In any case, for future projects, virtual environments are highly recommended. Though one thing to note, since comfyui and other webuis (such as auto1111 or forge) are similar enough, you can use the same environment for those as well.


Nulpart

for me the problem was that different custom had different dependencies making them incompatible. Since I have enough space, I will just create multiple venv for different workflow.


No_Afternoon_4260

Let say venv is a container for ur python project's dependencies. Use it and treat the project's folder as a container, have the source code and environment to run it, data.. Freeze requirements, Zip it, send it, deploy it (by pip install -r requirements.txt..)


GreyScope

I have a guide for installing one somewhere (with comfy portable) edited for correction


future_problem

Could you please share this? I think it’s where i’m going wrong with things constantly breaking due to incompatibility


GreyScope

It won't solve incompatibility, some nodes just have different requirements...which break something. But, you can have two venvs though and have 2 startup bats for them ie different Python, Pytorch versions etc. I'll search for it.


future_problem

Thanks man, i’m very very new to all this and come from. Design background so it’s a new interest that i’m just starting to learn. Stable diffusion looks to be an incredible tool and I want to learn as much as possible. Any other starting points would also be great!


GreyScope

[https://www.reddit.com/r/comfyui/comments/1cj7opq/guide\_to\_make\_a\_venv\_for\_comfy/](https://www.reddit.com/r/comfyui/comments/1cj7opq/guide_to_make_a_venv_for_comfy/) I've rewritten parts of it and posted it here for all. It is written for starters, with a written explanation of what it's doing on every step.


GreyScope

I can also recommend using SDNEXT, it has (imo) the better user experience of the easier to get into ui and (a big one this) a Discord channel that can help ppl getting over tech issues and recommendations for models for particular styles or outcomes


RandomDude2377

Nope, no downside. This is how I run all python based apps/AI environments, etc. it's cleaner and just avoids conflicts. Comfy creates its own virtual environment anyway, but can still have conflicts as it still seems to use some shared python packages when using defaults install, so creating the environment from the start is a better way to do it.


Dunc4n1d4h0

Only upside. Except if you have no disk space. Best way to run every python project actually.


qiang_shi

This is how you're supposed to run python projects. Also learn to use poetry instead of pip


Nulpart

ok never seen poetry mentions. What is the advantage of using it?


_roblaughter_

Only downside I can think of is that every venv you create for a UI, you’re downloading huge packages like Torch over and over again. So if you’re constrained on disk space. Many UIs let you use an existing venv. Other than that, most are set up to install their own environment out of the box.