I would like to install Python packages in the CI/CD pipeline using the uv package manager. I did not create a virtual environment because I would like to use the virtual machine's global Python interpreter. When I run the uv pip install <package>
script, I get the following error:
Requirement already satisfied: pip in /opt/hostedtoolcache/Python/3.12.4/x64/lib/python3.12/site-packages (24.1.1)
Collecting pip
Downloading pip-24.1.2-py3-none-any.whl.metadata (3.6 kB)
Downloading pip-24.1.2-py3-none-any.whl (1.8 MB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 1.8/1.8 MB 32.0 MB/s eta 0:00:00
Installing collected packages: pip
Attempting uninstall: pip
Found existing installation: pip 24.1.1
Uninstalling pip-24.1.1:
Successfully uninstalled pip-24.1.1
Successfully installed pip-24.1.2
Collecting uv
Downloading uv-0.2.23-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata (35 kB)
Downloading uv-0.2.23-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (13.4 MB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 13.4/13.4 MB 104.1 MB/s eta 0:00:00
Installing collected packages: uv
Successfully installed uv-0.2.23
error: No virtual environment found
Is it possible to install it into the global Python environment?
It is possible to install packages into the system Python using the --system
option:
uv pip install --system <packages>
The --system
option instructs uv
to instead use the first Python found in the system PATH
.
WARNING:
--system
is intended for use in continuous integration (CI) environments and should be used with caution, as it can modify the system Python installation.
Reference to Installing into arbitrary Python environments.