I'm using pyenv to manage Python versions on my MacBook Pro. I have a question about how pyenv handles shim paths for each version.
I've installed different Python versions using pyenv.
pyenv versions
system
3.10.16
3.11.9
3.11.9/envs/extra
3.11.11
* 3.12.4 (set by /Users/xxxxx/.pyenv/version)
3.12.4/envs/cost
3.12.4/envs/myproject
cost --> /Users/xxxxx/.pyenv/versions/3.12.4/envs/cost
myproject --> /Users/xxxxx/.pyenv/versions/3.12.4/envs/myproject
extra --> /Users/xxxxx/.pyenv/versions/3.11.9/envs/extra
However, when I try to run them using shims, only the default version works. The other versions show an error saying they're not specified.
shim path for python3.10
MySampleProject/src/MySampleProjectCDK (mainline) % /Users/xxxxx/.pyenv/shims/python3.10 --version
pyenv: python3.10: command not found
The `python3.10' command exists in these Python versions:
3.10.16
Note: See 'pyenv help global' for tips on allowing both
python2 and python3 to be found.
shim path for python3.11
MySampleProject/src/MySampleProjectCDK (mainline) % /Users/xxxxx/.pyenv/shims/python3.11 --version
pyenv: python3.11: command not found
The `python3.11' command exists in these Python versions:
3.11.9
3.11.9/envs/extra
3.11.11
extra
Note: See 'pyenv help global' for tips on allowing both
python2 and python3 to be found.
shim path for python3.12
MySampleProject/src/MySampleProjectCDK (mainline) % /Users/xxxxx/.pyenv/shims/python3.12 --version
Python 3.12.4
This is causing problems for a project I'm working on. I'm trying to build and test the project using Hatch for both Python 3.11
and 3.12
.
I want to know how to make Python 3.10 and 3.11 behave like Python 3.12 when I'm using the shim path
I'm using pyenv to manage Python versions on my MacBook Pro. I have a question about how pyenv handles shim paths for each version.
I've installed different Python versions using pyenv.
pyenv versions
system
3.10.16
3.11.9
3.11.9/envs/extra
3.11.11
* 3.12.4 (set by /Users/xxxxx/.pyenv/version)
3.12.4/envs/cost
3.12.4/envs/myproject
cost --> /Users/xxxxx/.pyenv/versions/3.12.4/envs/cost
myproject --> /Users/xxxxx/.pyenv/versions/3.12.4/envs/myproject
extra --> /Users/xxxxx/.pyenv/versions/3.11.9/envs/extra
However, when I try to run them using shims, only the default version works. The other versions show an error saying they're not specified.
shim path for python3.10
MySampleProject/src/MySampleProjectCDK (mainline) % /Users/xxxxx/.pyenv/shims/python3.10 --version
pyenv: python3.10: command not found
The `python3.10' command exists in these Python versions:
3.10.16
Note: See 'pyenv help global' for tips on allowing both
python2 and python3 to be found.
shim path for python3.11
MySampleProject/src/MySampleProjectCDK (mainline) % /Users/xxxxx/.pyenv/shims/python3.11 --version
pyenv: python3.11: command not found
The `python3.11' command exists in these Python versions:
3.11.9
3.11.9/envs/extra
3.11.11
extra
Note: See 'pyenv help global' for tips on allowing both
python2 and python3 to be found.
shim path for python3.12
MySampleProject/src/MySampleProjectCDK (mainline) % /Users/xxxxx/.pyenv/shims/python3.12 --version
Python 3.12.4
This is causing problems for a project I'm working on. I'm trying to build and test the project using Hatch for both Python 3.11
and 3.12
.
I want to know how to make Python 3.10 and 3.11 behave like Python 3.12 when I'm using the shim path
Share asked Mar 3 at 20:06 Am1rr3zAAm1rr3zA 7,44118 gold badges87 silver badges134 bronze badges 2 |1 Answer
Reset to default 0The solution that worked for me was to use: https://github/pyenv/pyenv/blob/master/COMMANDS.md#pyenv-local-advanced
I tried to run the below on my shell:
pyenv local 3.11.11 3.12.4
Now when I build with python hatch it can find both version of python locally
I attempted various approaches and one other way of doing this is to use mise]1
Since it appears that mise is an alternative method for managing Python, and its approach to handling shim paths and the default PATH differs, I attempted to synchronize my pyenv
version with mise
to add them to the PATH.
https://mise.jdx.dev/cli/sync/python.html
mise sync python --pyenv
mise use [email protected] [email protected]
/Users/xxxxx/.pyenv/shims
there ispython3.10.16
instead ofpython3.10
then I would simply copy it to new namecp python3.10.16 python3.10
or (on Linux) I would create "soft link"ln -s python3.10.16 python3.10
. I usesoft links
also with folder to other tools - ie. if I have two versions ofPyCharm
then I can keep them in foldersPyCharm-old-version
,PyCharm-new-version
and I can useln -s ...
to create folderPyCharm
which links to folderPyCharm-old-1
and other day I can change link toPyCharm-new-version
- this way I don't have to change all my scripts – furas Commented Mar 5 at 3:26ln
also to create link/usr/bin/python3.12
but I don't change/usr/bin/python3
because system uses Python3 to run some elements. – furas Commented Mar 5 at 3:43