Create a Python development environment in 10 minutes (Mac OS X + Visual Studio Code)

Make a note as a memorandum.

reference

I referred to the following article.

Qiita: Python environment construction on Mac

Overview

With the goal of installing the following and debugging on VS Code, The procedure is described below.

Install pyenv-virtualenv

pyenv-virtualenv is a tool that manages the version of the operating environment, like rbenv in ruby and nvm in node.js. Not only is it easy to switch versions for each application, but it is also possible to create virtual environments within the same version.

export PYENV_ROOT=/usr/local/var/pyenv
if which pyenv > /dev/null; then eval "$(pyenv init -)"; fi
if which pyenv-virtualenv-init > /dev/null; then eval "$(pyenv virtualenv-init -)"; fi

Reflect the settings and check if it works properly

$ source ~/.bash_profile
$pyenv

Latest Python installation

Create working folder

Create a virtual environment with pyenv-virtual and apply it to the created working folder.

$ mkdir dev
$ cd dev

installation of flake8

flake8 is Python's Linter. pip install flake8

yapf yapf is a Python code formatting tool. pip install yapf

mypy mypy is a code analysis tool. It does type checking statically like Typescript. I personally feel relieved to have it, so I will introduce it. pip install mypy

Visual Studio Code settings

python


{
   "python.linting.flake8Enabled": true,
   "python.formatting.provider": "yapf",
   "python.linting.mypyEnabled": true
}

Open the debug screen with Cmd + Shift + D, click the gear mark on the upper left, and click To add an item to test the currently open file, add the following description.

python


{
		"name": "Test This",
		"type": "python",
		"request": "launch",
		"stopOnEntry": false,
		"pythonPath": "${config.python.pythonPath}",
		"program": "${file}",
		"debugOptions": [
			"WaitOnAbnormalExit",
			"WaitOnNormalExit",
			"RedirectOutput"
		]
	}

Operation check

print('Hello, World')

Recommended Posts

Create a Python development environment in 10 minutes (Mac OS X + Visual Studio Code)
Create a Python development environment on Windows (Visual Studio Code remote WSL).
Build a Python development environment on Mac OS X
Create a Python development environment on OS X Lion
Set up a Python development environment with Visual Studio Code
Try to create a python environment with Visual Studio Code & WSL
Build Python development environment with Visual Studio Code
[Docker] Create a jupyterLab (python) environment in 3 minutes!
Python development in Visual Studio 2017
Python development in Visual Studio
Python development environment with Windows + Anaconda3 + Visual Studio Code
Python development environment with Windows + Python + PipEnv + Visual Studio Code
Create a Python environment on Mac (2017/4)
Create a Python (pyenv / virtualenv) development environment on Mac (Homebrew)
Create a GO development environment with [Mac OS Big Sur]
Do something like a Python interpreter in Visual Studio Code
Create a Python environment for professionals in VS Code on Windows
Mac OS X Mavericks 10.9.5 Development environment construction
Create a python environment on your Mac
Continuation ・ Notes on preparing the Python development environment on Mac OS X
Bash, Python, Javascript, code command, etc. in Visual Studio Code on Mac
Mac OS X Yosemite 10.10 Development environment construction
Mac OS X development environment construction memo
Create a simple Python development environment with VS Code and Docker
Create a Vim + Python test environment in 1 minute
Create a virtual environment with conda in Python
Build a Python development environment on your Mac
Think about building a Python 3 environment in a Mac environment
Mac OS X Mountain Lion 10.8.5 Development environment construction
Settings for Python coding in Visual Studio Code
Create a Python virtual development environment on Windows
[Note] How to create a Mac development environment
Create a Python environment
Development environment in Python
I get an error when I put a Python plugin in Visual Studio Code under the pyenv environment
I want to create a nice Python development environment for my new Mac
Run Qiita API v2 Python wrapper in Python3 environment (Mac OS X 10.11 (El Capitan))
Build a machine learning Python environment on Mac OS
App development to tweet in Python from Visual Studio 2017
Create a comfortable Python 3 (Anaconda) development environment on windows
Create a python development environment with vagrant + ansible + fabric
AWS SDK for Python (Boto3) development in Visual Studio 2017
Building a Python environment for programming beginners (Mac OS)
Create a function in Python
Create a dictionary in Python
Enable the virtualenv Python virtual environment for Visual Studio Code
Create a VS Code + Docker development environment on a Linux VM
Build a Python development environment in Eclipse (add HTML editor)
Building a development environment for Android apps-creating Android apps in Python
Prepare Python development environment with Mac + Windows + VisualStudio Code (Windows version)
Prepare Python development environment with Mac + Windows + VisualStudio Code (Mac version)
Create code that outputs "A and pretending B" in python
Create a simple Python development environment with VSCode & Docker Desktop
Build a python environment with pyenv (OS X El Capitan 10.11.3)
UpNext2 Development Record # 1 Build Python CI environment in VS Code
Create a virtual environment for python on mac [Very easy]
Building a Python environment on Mac
Create a DI Container in Python
Create a virtual environment with Python!
Create a binary file in Python
Create a python environment on centos