Pyenv
lastmod 2026-09-04created 2016-04-2528 edits
Simple Python Version Management: pyenv.
How to install
Simple usage
pyenv versions ## 설치된 버전 목록
pyenv install --list ## 설치 가능한 버전 목록
pyenv install 3.9.11 ## 3.9.11 버전 설치
pyenv uninstall 3.9.11 ## 3.9.11 버전 삭제
pyenv virtualenv 3.9.1 py39 ## 3.9.11 버전을 기반으로 py39 라는 가상환경 설치 (`pyenv install 3.9.11` 이 선결되어야 한다)
Commands
| Subcommand | Description |
| local | Check and set the python version for the current directory |
| global | Globally set python version |
| shell | Set the Python version for the shell |
| install | Install a Python version using python-build |
| uninstall | Remove the specified Python version |
| version | Print the currently active Python version |
| versions | Print the versions installed with pyenv and available for use |
| which | Print the location of the active Python command |
| whence | Print all Python versions that contain the specified command |
Mac OSX
On Mac OSX, you can install it via brew as follows.
If you use the pyenv root directory installed by brew (note: the default directory is ~/.pyenv), you must add the following to your profile.
Add the following to your profile and you're done.
Of course, if you want to apply the above environment right away, you need to load the profile as follows.
| Check! |
| If you also want to manage package dependencies with pip, you need to install virtualenv. |
How to build CPython with Framework support on OS X
How to build CPython with --enable-shared
How to use
You can see the list of installable Python versions with the following command.
| INFORMATION |
| If the latest Python version is missing, go to |
Then enter a version name found above to install it.
To check the Python version currently in use, enter the following.
Note that if it prints system, you are using the Python installed on the system.
To see all currently installed Python versions, enter the following.
Create a Virtual Environment:
Then activate it:
To deactivate:
Run pip and check the package list. Only pip and setuptools should be there.
Update bash profile
See the site for the exact details. Use the content below for reference only.
Troubleshooting
no such command shell
If you get an error that the shell command cannot be found1, you need to apply the following command.
The Python ssl extension was not compiled. Missing the OpenSSL lib?
If you have homebrew openssl and pyenv installed, you may need to tell the compiler where the openssl package is located:
CFLAGS="-I$(brew --prefix openssl)/include" \
LDFLAGS="-L$(brew --prefix openssl)/lib" \
pyenv install -v 3.4.3
pyenv: shell integration not enabled. Run `pyenv init' for instructions
This summarizes how to deal with the following error.
1. If the following code is not in ~/.bash_profile, add it.
export PYENV_ROOT="$HOME/.pyenv"
command -v pyenv >/dev/null || export PATH="$PYENV_ROOT/bin:$PATH"
eval "$(pyenv init -)"
2. When integrating into a script, you can use which to assign it to a variable and then run the command.
When used as above, the timing of exporting the PATH environment variable
From then on, use pyenv instead of "$PYENV_EXE".
Using the eval command can tangle the paths in use and cause the error above.
prompt changing will be removed from future release
See Virtualenv#prompt changing will be removed from future release.
In short, this happens because the pyenv-virtualenv environment has changed. Leave it as is.
Local Download
- Pyenv-a8664a2.tar.gz
- Latest commit a8664a2
- Download: 2016-05-04
See also
- Shell:Hooks - about how it works
- mise
- direnv
- pyenv: Python version management.
- Virtualenv: Python package dependency management.
- autoenv: automatic environment (Environments) setup.
- venv: Python venv
Favorite site
- Github: pyenv project site
- Building a Python development environment with pyenv + virtualenv + autoenv 2