-
Notifications
You must be signed in to change notification settings - Fork 803
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
uv pip install --system
cannot create directory
#2059
Comments
My initial reaction is that we're unlikely to support this. (I'm also unsure how Can you say more about the use-case? Why attempt to install into a directory for which you don't have write access? |
I would like some packages like pre-commit to be installed globally on the system so that so that I do not have to source an environment everytime I commit, if the repo is not related to python, or in a mono-repo where a child directory specifices the python requirements. |
This is something I encounter regularly on Linux and Windows systems managed by companies, universities, research institutes, or other organizations: Python is installed system-wide and has system-wide packages in How to reproduce on a fresh Ubuntu 22.04: $ sudo apt install python3-pip python3-is-python
$ pip install numpy # install as "normal" user
$ sudo su - # switch to root
# pip install pandas # install as root
$ exit # switch to "normal" user
$ python
>>> import numpy, pandas
>>> numpy.__file__
'/home/username/.local/lib/pythonX.X/site-packages/numpy/__init__.py'
>>> pandas.__file__
'/usr/local/lib/pythonX.X/dist-packages/pandas/__init__.py' To me this seems to be desirable behavior for pip outside of venv. But I would understand if you don't want to support this because you (iiuc) want to encourage venv usage and added |
What does |
|
To clarify, pip supports installing to |
Yeah, this makes sense. I see the fallback here: if the directory isn't writeable, they assume |
This was also requested here: #1584. I'm more open to supporting |
In case you don't want to implement this automatic fallback, I think a more specific error message would be helpful (e.g. pointing to |
Definitely! |
I've been trying to be "good" and use |
(Aside: we plan to add |
@charliermarsh Is this similar to pypa/pipx#754 which is approved in pypa/pipx#1281 ? That PR will add support for |
No, I was more referring to the idea of adding pipx install-like behavior in general. |
Are there plans to add support for global packages in uv? Specially venv for multi-users? |
Can you say more about what a global package is, and what use-case you’re trying to accomplish? |
Global packages allows you to install isolated applications at the system(global) level. These can be applications/cli's managed by admins for systems with multiple users. Example:
All users should be able to use both cli A and B. Without the global/system feature these packages dependencies will conflict. The PR from pipx allows for these to be installed in isolated environments but available to all users at the global/system level. |
Yeah, that’s something we want to transparently support in the future. |
Is there a recommended workaround for this issue other than using a venv? If not, I can take a shot at implementing the |
@ulasozguler when system python's directory has not Write access, it's recommended to use isolated python environment for installing tools. You can use pipx for such case which create isolated python for each tool and also expose to globally use. Also, uv has pipx-like feature which is in preview now: |
@T-256 pipx added support for global venv back in May with v1.5.0 The main purpose is for tools/cli's that are used by multiple users in the same system. For example |
(Wrong person mentioned in previous comment, edited)
@gaby Correct, that is purpose of this issue 👍 |
I'm not actually trying to install a shared tool, it's just a package that would normally (with My environment is in a Docker container, where I don't really need another python environment. I didn't want to add a venv to avoid increasing complexity, and I didn't want to run |
I don't currently plan to support |
@charliermarsh The |
But it seems natural that those containers could just use a virtual environment? In practice, you may also be able to use |
Please see the extensive discussion at #2077 regarding the |
I think it's totally fair not to include it. The only reason I mentioned it is that it sounded like you were planning to add it in a previous comment.
FROM ghcr.io/astral-sh/uv:0.2.24 as uv
FROM python:3.11.6
COPY --from=uv /uv /bin/uv
# Copy requirements file
WORKDIR /code
ARG REQFILE=requirements.txt
COPY $REQFILE .
# Do NOT use root
ARG USERNAME=appuser
RUN useradd -m $USERNAME
USER $USERNAME
# Install python dependencies
ENV PATH="/home/$USERNAME/.local/bin:$PATH"
ENV UV_HTTP_TIMEOUT=100 \
UV_NO_CACHE=1 \
UV_SYSTEM_PYTHON=1
RUN uv pip install -r $REQFILE --prefix "/home/$USERNAME/.local/" |
uv --version
).pip defaults to
.local/lib/python3.12/site-packages/
if the directory is not writeableThe text was updated successfully, but these errors were encountered: