Create Python Virtual Environment at a Custom Path


# Specify a custom path using --prefix 
$ mamba create --prefix=/home/t480s/.local/python/py3.12 python==3.12 


 $ mamba env list 
 Name Active Path ────────────────────────────────────────────────────                                                /home/t480s/.local/python/py3.12 

 base      *       /opt/miniforge3 


# Give a meaningful name to the python environment 
$ mamba config --append envs_dirs /home/t480s/.local/python 

 $ mamba env list 

Name Active Path ──────────────────────────────────────────────────── 
 py3.12          /home/t480s/.local/python/py3.12 
 base      *     /opt/miniforge3 

# Activate the environment 
$ mamba activate py3.12 
 (/home/t480s/.local/python/py3.12) [t480s@t480s python]$ python --version 
Python 3.12.0 

# De-activate the environment 
(/home/t480s/.local/python/py3.12) [t480s@t480s python]$ mamba deactivate 
[t480s@t480s python]$

Comments

Popular posts from this blog

uv as a replecement for pip