My Python notes
Commands I use while learning Python — set up environment
My Python notes — pyenv and pyenv-virtualenv
Set your Python virtual environment so you will not get into pip dependency mess.
For each major projects you do, create it’s own environment.
1. Virtual envinroment
Install pyenv and pyenv-virtualenv plugin
- pyenv is used for having multiple Python versions on one computer
- pyenv-virtualenv is used for having multiple Python environments.
brew install pyenv
brew install openssl readline sqlite3 xz zlib
brew install pyenv-virtualenv
2. Add pyenv to your shell
into file ~/.zshrc or ~/.bash_profile depending on your shell
export PYENV_ROOT="$HOME/.pyenv"
export PATH="$PYENV_ROOT/bin:$PATH"
eval "$(pyenv init --path)"
eval "$(pyenv init -)"
restart your shell.
3. Install Python versions you need
Before installing this, you have only default system Python from your MacOS. Do not install Python via brew or via www.python.org
See which versions of Python are avaiable
pyenv install --list
and install the Python version you like
pyenv install 3.12.11
python --version # check the version of Python, should be 3.12.11
This will install Python version 3.12.11 (into directory $HOME/.pyenv/versions), you can install any version you need or even more of them using the same command.
4. Set global or local version
pyenv global 3.12.11 # default for all shells
pyenv local 3.12.11 # in a specific project folder, can be different version
5. Create virtual envinroment
Create virtual envinroment testenv1
#pyenv virtualenv <python_version> <environment_name>
pyenv virtualenv 3.12.11 testenv1
This will create new envonroment called testenv1 in Python version 3.12.11, which we have instaled in the directory $HOME/.pyenv/versions/3.12.11/testenv1
For deleting testenv1 use the command
#pyenv uninstall <environment_name or python version>
pyenv uninstall testenv1
6. Activate virtual envinroment
#pyenv activate <environment_name>
pyenv activate testenv1
This will activate the envinroment.
For deactivating use
pyenv deactivate
7. Listing what you have installed
This command will show all Python versions and envs you have installed
pyenv versions
Examle output:

example
메타데이터
- post_id
- 1e84e386ad9d
- slug
- my-python-notes-1e84e386ad9d
- url
- https://medium.com/@ertra/my-python-notes-1e84e386ad9d
- canonical_url
- https://medium.com/@ertra/my-python-notes-1e84e386ad9d
- author_url
- https://medium.com/@ertra
- status
- ok
- fetched_at
- 2026-08-04 23:03:49