Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

venv must be activated even when running via venv/bin/python -m uv #1501

Closed
altendky opened this issue Feb 16, 2024 · 1 comment · Fixed by #1504
Closed

venv must be activated even when running via venv/bin/python -m uv #1501

altendky opened this issue Feb 16, 2024 · 1 comment · Fixed by #1504
Assignees
Labels
bug Something isn't working

Comments

@altendky
Copy link

Seems likely related to #1374. I expect that even if usage outside of a venv is blocked, either universally by uv or because of PIP_REQUIRE_VIRTUALENV=1, activation should not be required as many people prefer to venv/bin/python instead of using source venv/bin/activate; python.

$ python3.11 -m venv venv
$ venv/bin/python -m pip install 'uv @ git+https://github.com/astral-sh/uv@1ed6ba0ba0d3756312085ec21c90469985b5bbb6'
Collecting uv@ git+https://github.com/astral-sh/uv@1ed6ba0ba0d3756312085ec21c90469985b5bbb6
  Using cached uv-0.1.2-py3-none-linux_x86_64.whl
Installing collected packages: uv
Successfully installed uv-0.1.2

[notice] A new release of pip is available: 23.2.1 -> 24.0
[notice] To update, run: /home/altendky/tmp/venv/bin/python -m pip install --upgrade pip
$ venv/bin/python -m uv pip install --force-reinstall attrs
error: Failed to locate a virtualenv or Conda environment (checked: `VIRTUAL_ENV`, `CONDA_PREFIX`, and `.venv`). Run `uv venv` to create a virtualenv.

Above should work just as below does.

$ venv/bin/python -m pip install --force-reinstall attrs
Collecting attrs
  Obtaining dependency information for attrs from https://files.pythonhosted.org/packages/e0/44/827b2a91a5816512fcaf3cc4ebc465ccd5d598c45cefa6703fcf4a79018f/attrs-23.2.0-py3-none-any.whl.metadata
  Downloading attrs-23.2.0-py3-none-any.whl.metadata (9.5 kB)
Downloading attrs-23.2.0-py3-none-any.whl (60 kB)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 60.8/60.8 kB 844.6 kB/s eta 0:00:00
Installing collected packages: attrs
Successfully installed attrs-23.2.0

[notice] A new release of pip is available: 23.2.1 -> 24.0
[notice] To update, run: /home/altendky/tmp/venv/bin/python -m pip install --upgrade pip
$ source venv/bin/activate

Just showing that below the same command works after the activation above.

(venv) $ venv/bin/python -m uv pip install --force-reinstall attrs
Resolved 1 package in 1ms
Installed 1 package in 2ms
 - attrs==23.2.0
 + attrs==23.2.0
@zanieb zanieb self-assigned this Feb 16, 2024
@zanieb zanieb added the bug Something isn't working label Feb 16, 2024
@zanieb
Copy link
Member

zanieb commented Feb 16, 2024

Thanks for the well written issue!

Related #1396

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants