webmaster-kazu.com

テクノロジー・データ分析・実践ログ・その他

モジュラーソースコードチェッカー「flake8」のインストール

カテゴリ: Python【初歩から現場実務的なもの】

モジュラーソースコードチェッカー「flake8」のインストールについて解説しています。

「flake8(https://github.com/pycqa/flake8)」は、pycodestyle、pyflakes、mccabe、及びサードパーティのプラグインを結合して、一部のPythonコードのスタイルと品質をチェックできるPythonライブラリ、もしくはツールです。

■Python

今回のPythonのバージョンは、「3.8.5」を使用しています。(Windows10)(pythonランチャーでの確認)

■flake8をインストールする

flake8をインストールを行いますが、今回はpipを経由してインストールを行うので、まずWindowsのコマンドプロンプトを起動します。

pip install flake8

起動後、上記のコマンドを入力し、Enterキーを押します。

なお、今回は、pythonランチャーを使用しており、Python Version 3.8.5にインストールを行うために、バージョンの切り替えを行います。

py -3.8 -m pip install flake8

切り替えるために、上記のコマンドを入力し、Enterキーを押します。

Defaulting to user installation because normal site-packages is not writeable

Collecting flake8

Downloading flake8-4.0.1-py2.py3-none-any.whl (64 kB)

---------------------------------------- 64.1/64.1 kB 854.8 kB/s eta 0:00:00

Collecting pyflakes<2.5.0,>=2.4.0

Downloading pyflakes-2.4.0-py2.py3-none-any.whl (69 kB)

---------------------------------------- 69.7/69.7 kB 1.9 MB/s eta 0:00:00

Requirement already satisfied: pycodestyle<2.9.0,>=2.8.0 in c:\users\user_\appdata\roaming\python\python38\site-packages (from flake8) (2.8.0)

Collecting mccabe<0.7.0,>=0.6.0

Downloading mccabe-0.6.1-py2.py3-none-any.whl (8.6 kB)

Installing collected packages: mccabe, pyflakes, flake8

Successfully installed flake8-4.0.1 mccabe-0.6.1 pyflakes-2.4.0

Enterキーを押すと、インストールが開始され、上記のように「Successfully installed」と表示されます。これが表示されれば、flake8が正常にインストールされたことになります。

なお、今回はflake8のバージョン4.0.1をインストールしました。