最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

python - `.venvlib` gets deleted just after creation on MacOS - Stack Overflow

programmeradmin0浏览0评论

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!

Share Improve this question asked Mar 28 at 5:19 theresjustnotimetheresjustnotime 211 bronze badge 3
  • Try changing the folder name and see if it makes any difference, maybe that can give a clue. – Mikko Ohtamaa Commented Mar 28 at 6:15
  • 1 @MikkoOhtamaa Yep, changing the name quickly after creating keeps it safe, so there must be something watching .venv specifically – theresjustnotime Commented Mar 28 at 6:23
  • It's likely some local application you have installed on your computer. – Mikko Ohtamaa Commented Mar 28 at 6:42
Add a comment  | 

1 Answer 1

Reset to default 0

If 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.

发布评论

评论列表(0)

  1. 暂无评论