Creating a venv with uv does not use the correct python version #3630
Replies: 4 comments 3 replies
-
does |
Beta Was this translation helpful? Give feedback.
-
Hi, not I tried to set it via the settings and it does not change anything (it is set to |
Beta Was this translation helpful? Give feedback.
-
Wrong python version in venv auto creation
I can't recreate this. I tried in a fresh mise environment Debian 12 bookworm, click here to see what I did.~/Code/sandbox
❯ docker run --pull=always -it --rm --entrypoint bash jdxcode/mise:latest
[docker] $ docker run --pull=always -it --rm --entrypoint bash jdxcode/mise:latest
latest: Pulling from jdxcode/mise
Digest: sha256:47b5d9a3dfcdc81563c6de6c759301ace63753d28547752610377a6560e4230f
Status: Image is up to date for jdxcode/mise:latest
root@a7f380f997a9:/mise# cd /srv Install and open fish shell then activate mise root@a7f380f997a9 /srv# apt update; apt install fish -y; exec fish -l;
Hit:1 http://deb.debian.org/debian bookworm InRelease
Hit:2 http://deb.debian.org/debian bookworm-updates InRelease
Hit:3 http://deb.debian.org/debian-security bookworm-security InRelease
Reading package lists... Done
...
Welcome to fish, the friendly interactive shell
Type help for instructions on how to use fish
root@a7f380f997a9 /srv# mise activate fish | source
root@a7f380f997a9 /srv# ps
PID TTY TIME CMD
1 pts/0 00:00:00 fish
386 pts/0 00:00:00 ps I removed the pre-install python tool in the docker container: root@a7f380f997a9 /srv# echo "" > /mise/config.toml
root@a7f380f997a9 /srv# mise uninstall --all
mise [email protected] ✓ uninstalled I created a symlink so root@a7f380f997a9 /srv# ln -s /usr/bin/python3 /usr/bin/python
root@a7f380f997a9 /srv# which python
/usr/bin/python
root@069e412150ca /srv# python --version
Python 3.11.2 I install uv and copied your settings from root@a7f380f997a9 /srv# mise use -g uv
mise [email protected] ✓ installed
mise /mise/config.toml tools: [email protected]
root@a7f380f997a9 /srv# mise settings experimental=true
root@a7f380f997a9 /srv# mise settings python.uv_venv_auto=true
root@a7f380f997a9 /srv# mise settings python.venv_stdlib=false
root@a7f380f997a9 /srv# mise settings
Key Value Source
experimental true /mise/config.toml
python.uv_venv_auto true /mise/config.toml
python.venv_stdlib false /mise/config.toml Create your .mise.toml: root@a7f380f997a9 /srv# echo '[env]
_.file = ".env"
_.python.venv = { path = ".venv", create = true }
[tools]
python = { version = "3.10" }
' >issue-3325/.mise.toml
root@a7f380f997a9 /srv# mise trust ./issue-3325
mise trusted /srv/issue-3325 Now root@a7f380f997a9 /srv# cd issue-3325/
mise WARN no venv found at: /srv/issue-3325/.venv
To create a virtualenv manually, run:
python -m venv /srv/issue-3325/.venv
root@a7f380f997a9 /s/issue-3325# ls -a
./ ../ .mise.toml Now run mise install and see the python version is correct in the new .venv: root@a7f380f997a9 /s/issue-3325# mise install
mise WARN libgit2 failed: cannot force update branch 'master' as it is the current HEAD of the repository.; class=Reference (4)
mise hint use multiple versions simultaneously with mise use [email protected] [email protected]
mise hint installing precompiled python from indygreg/python-build-standalone
if you experience issues with this python (e.g.: running poetry), switch to python-build by running mise settings python.compile=1
mise WARN no venv found at: /srv/issue-3325/.venv
To create a virtualenv manually, run:
python -m venv /srv/issue-3325/.venv
mise [email protected] ✓ installed mise creating venv with uv at: /srv/issue-3325/.venv
Using CPython 3.10.16 interpreter at: /mise/installs/python/3.10.16/bin/python
Creating virtual environment at: .venv
root@a7f380f997a9 /s/issue-3325# .venv/bin/python --version
Python 3.10.16 Leave the dir, rm the venv, and re-enter to see the correct version is used. root@a7f380f997a9 /s/issue-3325# cd ../
root@a7f380f997a9 /srv# rm -rf issue-3325/.venv/
root@a7f380f997a9 /srv# cd issue-3325/
mise creating venv with uv at: /srv/issue-3325/.venv
Using CPython 3.10.16 interpreter at: /mise/installs/python/3.10.16/bin/python
Creating virtual environment at: .venv Unless you can help me recreate the issue, I can't do much to help. Perhaps you can share your path? Maybe you have something overriding your python version. If we can recreate this issue then it's definitely a bug we should try to fix. No pip in .venvI don't get pip in venv even when I manually create it with with I tested this in the same environment I created to test the first issue, click here to see what I did.root@a7f380f997a9 /s/issue-3325# sed 's/true/false/' -i .mise.toml
root@a7f380f997a9 /s/issue-3325# cat .mise.toml
[env]
_.file = ".env"
_.python.venv = { path = ".venv", create = false }
[tools]
python = { version = "3.10" }
root@a7f380f997a9 /s/issue-3325# rm -rf .venv
mise WARN no venv found at: /srv/issue-3325/.venv
To create a virtualenv manually, run:
python -m venv /srv/issue-3325/.venv
root@a7f380f997a9 /s/issue-3325# uv venv
Using CPython 3.10.16 interpreter at: /mise/installs/python/3.10.16/bin/python
Creating virtual environment at: .venv
root@a7f380f997a9 /s/issue-3325# ls .venv/bin
activate activate.bat activate.csh activate.fish activate.nu activate.ps1 activate_this.py deactivate.bat pydoc.bat python@ python3@ python3.10@ Next stepsWait for author @FlorianGD to provide reproducible steps or tell us if he can't recreate it in a fresh environment. |
Beta Was this translation helpful? Give feedback.
-
I've been digging into this bit of the code today and yes, it uses whatever is in your path. I have a hunch you are running into the issue described here: #2718 tldr; the theory is that you've manually activated a venv (e.g. Can you start a fresh shell, make sure you have no active venvs, then try to recreate the issue again? |
Beta Was this translation helpful? Give feedback.
-
Hello,
First, thanks for the great tool, I have been using it and advising people to use it for quite some time, it is really valuable ! I regularly update the tool via
cargo install-update
, and it seems I have been bitten by using the latest version.Describe the bug
When setting a new python project, I want
mise
to create and activate the virtual env for me, using the version given in.mise.toml
. It used to work fine.The latest version seems to use
uv
to create the virtual env, resulting in the wrong python version being installed.To Reproduce
With the setting
python.venv_stdlib
asfalse
, and with the following.mise.toml
When I enter the directory with no
.venv
created, this is what I see:Notice the
using CPython 3.11.10
when I want python3.10
as per the.mise.toml
file.Moreover, I do not have the
pip
binary in the virtualenv. Manually activating the env does not change it.If I change the setting
python.venv_stdlib
astrue
, then I have the correct behavior (though, the creation is slower because it does not useuv
anymore)Expected behavior
I'd like to create the virtualenv with uv and having the correct python version installed in the virtual environment.
I have
uv
installed externally of the project, usingpipx
and python version3.12
if that matters.Setting
python.uv_venv_auto
does not seem to change as this project does not useuv.lock
.mise doctor
outputAdditional context
I use ubuntu 20.04.
Beta Was this translation helpful? Give feedback.
All reactions