I’ve been working on a project for a while but all of a sudden my .venv
broke. Initially it created duplicates of a bunch of files inside .venv/lib
, (e.g. file
, file 2
, file 3
, ...), so I deleted the venv and decided to recreate it: uv venv .venv
. Upon recreating it, it's fine for about a second, and then the whole .venv/lib
directory gets deleted.
I have no clue what could be causing this but its really frustrating, and I've explored a bunch of things:
- It seems to be only happen in this project directory
- If I call the venv any other name, it doesn't happen
- It seems to happen whether or not Pycharm is active (my editor)
- Also happens if I create the venv with
python -m venv .venv
It is also in my .gitignore
. I've tried using some other directory watching tools but find the output too confusing/too precise the processes modifying it which seem to be mac-OS processes like fileproviderd
. Any ideas of what it could be or other things I could try to track it down would be greatly appreciated!
I’ve been working on a project for a while but all of a sudden my .venv
broke. Initially it created duplicates of a bunch of files inside .venv/lib
, (e.g. file
, file 2
, file 3
, ...), so I deleted the venv and decided to recreate it: uv venv .venv
. Upon recreating it, it's fine for about a second, and then the whole .venv/lib
directory gets deleted.
I have no clue what could be causing this but its really frustrating, and I've explored a bunch of things:
- It seems to be only happen in this project directory
- If I call the venv any other name, it doesn't happen
- It seems to happen whether or not Pycharm is active (my editor)
- Also happens if I create the venv with
python -m venv .venv
It is also in my .gitignore
. I've tried using some other directory watching tools but find the output too confusing/too precise the processes modifying it which seem to be mac-OS processes like fileproviderd
. Any ideas of what it could be or other things I could try to track it down would be greatly appreciated!
1 Answer
Reset to default 0If you are using uv, do NOT use python and other commands, and do NOT create venv manually.
To create a new uv project, simply:
uv init <project_name>
cd <project_name>
This already will give you the venv, etc.
Then to add and install dependencies:
uv add <pip package name>
This will add the pacakge to your toml file and will install it into the venv folder.
Finally, to run your scripts:
uv run scripts/my_script.py
You can also use the arkalos, which is built on the top of the uv, and gives you the whole project setup that just works out of the box.
https://arkalos/docs/new-project/
And you can create your modules inside the app folder, and import them into scripts or notebooks.
.venv
specifically – theresjustnotime Commented Mar 28 at 6:23