admin管理员组文章数量:1401122
I went to my project directory and ran
uv init
thinking that this would create a default virtual environment. It did not. I added in a few dozen dependencies now appearing in myproject.toml But now I want to make this environment available outside uv for example I want to run
uvicorn myserver.py
Because I cannot of course run uvicorn uv run myserver.py
So to me the documents are not clear in uv about what the baseline is when doing
uv venv
I really need to know if it starts from the projects myproject.toml or something else. Will it start from scratch and ignore myproject.toml? overwrite myproject.toml etc? Please clarify. If it does start from scratch and ignore myproject.toml is there anyway to initialise a venv environent with myproject.toml contents?
Update: Can someone clarify if running uv sync will actually create the .venv I only did uv init in the project directory initially. So far its not creating the .venv directory.
I went to my project directory and ran
uv init
thinking that this would create a default virtual environment. It did not. I added in a few dozen dependencies now appearing in myproject.toml But now I want to make this environment available outside uv for example I want to run
uvicorn myserver.py
Because I cannot of course run uvicorn uv run myserver.py
So to me the documents are not clear in uv about what the baseline is when doing
uv venv
I really need to know if it starts from the projects myproject.toml or something else. Will it start from scratch and ignore myproject.toml? overwrite myproject.toml etc? Please clarify. If it does start from scratch and ignore myproject.toml is there anyway to initialise a venv environent with myproject.toml contents?
Update: Can someone clarify if running uv sync will actually create the .venv I only did uv init in the project directory initially. So far its not creating the .venv directory.
Share Improve this question edited Mar 25 at 13:57 Draco asked Mar 25 at 13:07 DracoDraco 635 bronze badges 7 | Show 2 more comments1 Answer
Reset to default 0I assume you mean pyproject.toml
.
I really need to know if it starts from the projects myproject.toml or something else. Will it start from scratch and ignore myproject.toml?
uv venv
creates a blank virtualenv – the only packages it installs are seed packages like pip
, when so directed (--seed
).
You don't generally need to explicitly do that, since uv
works with the convention that a .venv
directory in your project directory is the project's virtualenv.
overwrite myproject.toml etc?
No, uv venv
doesn't touch your pyproject.toml file.
If it does start from scratch and ignore myproject.toml is there anyway to initialise a venv environent with myproject.toml contents?
uv sync
will ensure the project's virtualenv is up to date (creating one if needed). (If you don't have a virtualenv at .venv
, and want one to be created and your project's packages installed there, just uv sync
.)
Even more helpfully, uv run ...
will run a command with the project's virtualenv activated, syncing it beforehand by default.
IOW, uv init
(once), uv add
(when adding deps), uv run uvicorn myserver.py
are all you need in the basic case:
/v/f/n/6/T/tmp.l8JyBCoDzR $ uv init
Initialized project `tmp-l8jybcodzr`
$ uv add uvicorn fastapi[standard]
Using CPython 3.13.2 interpreter at: /opt/homebrew/opt/[email protected]/bin/python3.13
Creating virtual environment at: .venv
Installed 34 packages in 89ms
/v/f/n/6/T/tmp.l8JyBCoDzR (master) $ uv run uvicorn
Usage: uvicorn [OPTIONS] APP
Try 'uvicorn --help' for help.
...
本文标签:
版权声明:本文标题:uv python package manager. what is base environment when doing 'uv venv' does it include dependencies in project 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744194056a2594653.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
yourproject/.venv
by default, though this may change if you configure otherwise). – InSync Commented Mar 25 at 13:38