Notes on creating a python development environment on macOS Catalina

The aim is to build a python development environment

In the environment raised from Mojave to Catalina, when I did it normally, it did not work as expected with python3 or pip3 due to the difference in version, so I will try using around pyenv to see if it works well.

homebrew

Start from here.

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"

pyenv installation

$ brew install pyenv
$ pyenv -v
pyenv 1.2.17

Profile settings

$ echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.bash_profile
$ echo 'export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.bash_profile
$ echo -e 'if command -v pyenv 1>/dev/null 2>&1; then\n  eval "$(pyenv init -)"\nfi' >> ~/.bash_profile

https://github.com/pyenv/pyenv

By the way, in the case of zsh, it seems that the same settings should be made for .zshrc.

Zsh note: Modify your ~/.zshrc file instead of ~/.bash_profile. https://github.com/pyenv/pyenv

I don't know why it's .zshrc instead of .zprofile.

Reflect

$ source ~/.bash_profile

Install python by specifying the version

Check the installable version

$ pyenv install -l

Install the version you want to use

$ pyenv install 3.7.7

Confirmation of installation

$ pyenv versions
* system (set by /Users/ykinomt/.pyenv/version)
  3.7.7

Version switching

Status quo confirmation

$ python -V
Python 2.7.16

switching

$ pyenv global 3.7.7
$ python -V
Python 3.7.7

Use local to switch by directory.

$ python -V
Python 2.7.16
$ pyenv local 3.7.7
$ python -V
Python 3.7.7

If you use local, a file called .python-version will be created in that directory, and it will run with the specified version in that directory. If you want to create an application, it may be better to specify it as local.

vscode settings

It's not necessary, but the version that comes out in the interpreter settings seems to be the one that was installed by the time VSCode started, so if you newly install with the above settings, you may not be able to select it unless you restart vscode once.

Recommended Posts

Notes on creating a python development environment on macOS Catalina
Python development environment construction on macOS
Build a Python development environment using pyenv on MacOS
Build a python environment on MacOS (Catallina)
Creating a python virtual environment on Windows
Build a Python development environment on your Mac
Set up a Python development environment on Marvericks
Create a Python virtual development environment on Windows
Build a Python development environment on Raspberry Pi
Build a GVim-based Python development environment on Windows 10 (3) GVim8.0 & Python3.6
Create a comfortable Python 3 (Anaconda) development environment on windows
Build a GVim-based Python development environment on Windows 10 (1) Installation
Build a Python development environment on Mac OS X
Notes on creating a virtual environment with Anaconda Navigator
Create a Python development environment on OS X Lion
Building a Python environment on Mac
Prepare Python development environment on Ubuntu
Create a Python environment on Mac (2017/4)
Create a python environment on centos
Install Python development environment on Windows 10
Build a python3 environment on CentOS7
Build a python machine learning study environment on macOS sierra
Create a Python (pyenv / virtualenv) development environment on Mac (Homebrew)
Build a GVim-based Python development environment on Windows 10 (2) Basic settings
Until building a Python development environment using pyenv on Ubuntu 20.04
Addition of local development environment on MacOS
Python development environment for macOS using venv 2016
Blender 2.82 or later + python development environment notes
Continuation ・ Notes on preparing the Python development environment on Mac OS X
Python3 + venv + VSCode + macOS development environment construction
Install Python less than 3.5.3 on macOS Catalina
Build a Python + OpenCV environment on Cloud9
Building a Python development environment for AI development
Creating a development environment for machine learning
Things to watch out for when creating a Python environment on a Mac
Create a Python development environment on Windows (Visual Studio Code remote WSL).
Ubuntu18.04.05 Creating a python virtual environment in LTS
Simply build a Python 3 execution environment on Windows
Build a python environment with ansible on centos6
Build a Python environment on Mac (Mountain Lion)
[Python] Build a Django development environment with Docker
[Python] Web development preparation (building a virtual environment)
A memo when creating a python environment with miniconda
[Venv] Create a python virtual environment on Ubuntu
Commands for creating a python3 environment with virtualenv
Build a Kubernetes environment for development on Ubuntu
Procedure for creating a Python quarantine environment (venv environment)
Install Python 3 on MacOS Catalina (with Homebrew only)
A memo for creating a python environment by a beginner
Building a Python environment on a Sakura VPS server
Create a Python execution environment on IBM i
Install Python and libraries for Python on MacOS Catalina
Get a quick Python development environment with Poetry
Python development environment construction
About Python development environment
python2.7 development environment construction
Create a Python environment
Development environment in Python
Build a Django development environment using pyenv-virtualenv on Mac
Python: Creating a virtual environment (venv), starting and stopping
# 2 Build a Python environment on AWS EC2 instance (ubuntu18.04)