Overview
This article documents how to set up a Python environment for development on a Mac local environment.
In this case, we will use two systems to manage different versions of Python and virtual environments:
- pyenv
- Used to handle multiple versions of Python.
- venv
- Used to separate environments for each project.
For explanations on the differences and the necessity of each, this article is a helpful reference.
Installing Python
First, install Pyenv on your local environment to use a specific version of Python.
Install pyenv.
|
|
Check the installed version of pyenv.
|
|
Add settings to zsh.
|
|
Reload .zshrc
.
|
|
Display a list of installable Python versions.
|
|
Install the specified version.
|
|
Use the specified Python version in your project folder.
|
|
If global, it will be applied to the entire system.
|
|
Check the version of Python being executed.
|
|
Creating a Virtual Environment with venv
Create a virtual environment in the project directory.
|
|
Activate the virtual environment.
|
|
To deactivate, execute the following command.
|
|
This completes the setup of the local environment.