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 /srvInstall 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 psI 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] ✓ uninstalledI 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.2I 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.tomlCreate 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-3325Now 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.tomlNow 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.16Leave 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: .venvUnless 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: https://github.com/jdx/mise/issues/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.
Uh oh!
There was an error while loading. Please reload this page.
-
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
miseto 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
uvto create the virtual env, resulting in the wrong python version being installed.To Reproduce
With the setting
python.venv_stdlibasfalse, and with the following.mise.tomlWhen I enter the directory with no
.venvcreated, this is what I see:Notice the
using CPython 3.11.10when I want python3.10as per the.mise.tomlfile.Moreover, I do not have the
pipbinary in the virtualenv. Manually activating the env does not change it.If I change the setting
python.venv_stdlibastrue, then I have the correct behavior (though, the creation is slower because it does not useuvanymore)Expected behavior
I'd like to create the virtualenv with uv and having the correct python version installed in the virtual environment.
I have
uvinstalled externally of the project, usingpipxand python version3.12if that matters.Setting
python.uv_venv_autodoes not seem to change as this project does not useuv.lock.mise doctoroutputAdditional context
I use ubuntu 20.04.
Beta Was this translation helpful? Give feedback.
All reactions