Loading in venv no longer works
- Dominant language
- Python
- Stars
- 133k
- Forks
- 15.7k
- Avg merge
- 1d 7h
- Merged PRs (30d)
- 158
Description
### Custom Node Testing
- [x] I have tried disabling custom nodes and the issue persists (see [how to disable custom nodes](https://docs.comfy.org/troubleshooting/custom-node-issues#step-1%3A-test-with-all-custom-nodes-disabled) if you need help)
### Expected Behavior
Loading ComfyUI in the venv I prepared for it.
### Actual Behavior
It tells me sqlalchemy is not installed.
### Steps to Reproduce
I have a custom start script for this, which worked until yesterday with my existing and long running install. Still no idea why that one stopped working, as laid out in this report: [https://github.com/Comfy-Org/ComfyUI/issues/14694](https://github.com/Comfy-Org/ComfyUI/issues/14694)
But because I need it, and I don't expect a quick solution to that one, and I felt like doing some spring cleaning anyway I decided to just do a fresh install in a fresh venv with a newer Python version and only install the addons I actually need now.
So I did that, and now the script to run it in the venv yields the above result.
If I run the main.py script directly it works, but then it's not running in venv, which is not ideal.
Custom start script for running in venv is thus:
```
#!/bin/bash
# Activate virtual environment
source ComfyUI/bin/activate
# Verify the venv is active (optional - for debugging)
echo "Using Python from: $(which python)"
echo "Python version: $(python --version)"
# Change to the main directory before running
cd ComfyUI/ComfyUI
# Run the Python program
python main.py --port=7860 --enable-manager --enable-cors-header '*' --listen #--disable-dynamic-vram #--highvram #--disable-smart-memory
```
Ignore the disabled options, I've just been experimenting.
### Debug Logs
```powershell
'/home/username/Stable/ComfyUIStart.sh'
Using Python from: /home/username/Stable/ComfyUI/bin/python
Python version: Python 3.12.6
Traceback (most recent call last):
File "/home/username/Stable/ComfyUI/ComfyUI/main.py", line 22, in
from app.assets.seeder import asset_seeder
File "/home/username/Stable/ComfyUI/ComfyUI/app/assets/seeder.py", line 11, in
from app.assets.scanner import (
File "/home/username/Stable/ComfyUI/ComfyUI/app/assets/scanner.py", line 7, in
from app.assets.database.queries import (
File "/home/username/Stable/ComfyUI/ComfyUI/app/assets/database/queries/__init__.py", line 1, in
from app.assets.database.queries.asset import (
File "/home/username/Stable/ComfyUI/ComfyUI/app/assets/database/queries/asset.py", line 1, in
import sqlalchemy as sa
ModuleNotFoundError: No module named 'sqlalchemy'
```
### Other
Yes I am aware of https://github.com/Comfy-Org/ComfyUI/issues/14172 But that makes no mention of venv, and I am running this on linux, not windows.
Contributor guide
Research direction
Start by running the reported ComfyUIStart.sh script in the fresh virtual environment and follow the import chain from main.py through app/assets/seeder.py, app/assets/scanner.py, and app/assets/database/queries/asset.py. Check why the venv cannot import sqlalchemy while direct execution works; done means the venv launch reaches normal startup without the ModuleNotFoundError.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python, sqlalchemy
- Domain
- backend, databases
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 55/100