-
Notifications
You must be signed in to change notification settings - Fork 222
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
Error installing python packages using uv
#2411
Comments
I've also had the same issue, and tried to look into it. Although my error looks slightly different. Ended up resolving it by updating the UV_PYTHON environment variable to point to the python under the ExplanationThere are two locations where python executable is available in a devbox project.
Each of them have a related The UV_PYTHON default value will mean it will try to install and save libraries to the Related sources:Error$ uv pip install numpy
Using Python 3.12.1 environment at /nix/store/dnli4467fjzywkgwral3hr3xx33f8x2v-python3-3.12.1
error: The interpreter at /nix/store/dnli4467fjzywkgwral3hr3xx33f8x2v-python3-3.12.1 is externally managed, and indicates the following:
This command has been disabled as it tries to modify the immutable
`/nix/store` filesystem.
To use Python with Nix and nixpkgs, have a look at the online documentation:
<https://nixos.org/manual/nixpkgs/stable/
Consider creating a virtual environment with `uv venv`. Fix{
"env": {
"UV_PYTHON": "$PWD/.venv/bin/python"
},
"packages": [
"python@latest",
"uv@latest"
],
"shell": {
"init_hook": [
". $VENV_DIR/bin/activate",
"uv pip install -r requirements.txt"
],
"scripts": {
"run_test": "python main.py"
}
}
} $ devbox shell
Starting a devbox shell...
Warning: Your devbox environment may be out of date. Run refresh-global to update it.
Virtual environment directory doesn't exist. Creating new one...
Resolved 5 packages in 25ms
Installed 5 packages in 17ms
+ emoji==2.1.0
+ iniconfig==2.0.0
+ packaging==24.2
+ pluggy==1.5.0
+ pytest==8.3.4
$ echo $UV_PYTHON
/home/ubuntu/python-uv/.venv/bin/python
$ uv pip install numpy
Resolved 1 package in 108ms
Installed 1 package in 101ms
+ numpy==2.2.0 Investigating
$ echo $VENV_DIR
/home/ubuntu/python-uv/.venv
# follow path of python
$ which python
/home/ubuntu/python-uv/.venv/bin/python
$ ls -l /home/ubuntu/python-uv/.venv/bin/python
lrwxrwxrwx 1 ubuntu ubuntu 61 Dec 16 01:13 /home/ubuntu/python-uv/.venv/bin/python -> /home/ubuntu/python-uv/.devbox/nix/profile/default/bin/python
$ ls -l /home/ubuntu/python-uv/.devbox/nix/profile/default/bin/python
lrwxrwxrwx 1 ubuntu ubuntu 69 Jan 1 1970 /home/ubuntu/python-uv/.devbox/nix/profile/default/bin/python -> /nix/store/dnli4467fjzywkgwral3hr3xx33f8x2v-python3-3.12.1/bin/python
# site-packages under .venv is writable
$ ls -l .venv/lib/python3.12/
total 4
drwxrwxr-x 15 ubuntu ubuntu 4096 Dec 16 02:15 site-packages
$ echo $UV_PYTHON
/home/ubuntu/python-uv/.devbox/nix/profile/default/bin/python
$ ls -l $UV_PYTHON
lrwxrwxrwx 1 ubuntu ubuntu 69 Jan 1 1970 /home/ubuntu/python-uv/.devbox/nix/profile/default/bin/python -> /nix/store/dnli4467fjzywkgwral3hr3xx33f8x2v-python3-3.12.1/bin/python
# site-packages under .devbox/ is not writeable
$ ls -l .devbox/nix/profile/default/lib/
$ ls -l .devbox/nix/profile/default/lib/python3.12/
dr-xr-xr-x 2 ubuntu ubuntu 4096 Dec 16 02:38 site-packages |
I ran into this issue, I found that Realistically they are the same when you call the |
What happened?
When settings up devbox shell, setting up uv as a package to use as an installer, and then trying to use it to install numpy (or any other package) it complains with
Steps to reproduce
devbox shell
uv pip install numpy
Command
No response
devbox.json
Devbox version
0.13.6
Nix version
nix (Nix) 2.24.7
What system does this bug occur on?
Linux (x86-64)
Debug logs
No response
The text was updated successfully, but these errors were encountered: