webmaster-kazu.com

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

Mastodon API の Python ラッパー「mastodon.py」のインストール

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

Mastodon API の Python ラッパー「mastodon.py」のインストールについて解説しています。

「mastodon.py(https://github.com/halcy/Mastodon.py)」は、Mastodon (https://github.com/mastodon/mastodon/) API の Python ラッパーとなります。

■Python

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

■mastodon.pyをインストールする

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

pip install Mastodon.py

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

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

py -3.8 -m pip install Mastodon.py

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

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

Collecting Mastodon.py

Downloading Mastodon.py-1.7.0-py2.py3-none-any.whl (41 kB)

---------------------------------------- 41.7/41.7 kB 982.1 kB/s eta 0:00:00

Requirement already satisfied: decorator>=4.0.0 in c:\users\user_\appdata\roaming\python\python38\site-packages (from Mastodon.py) (5.1.1)

Requirement already satisfied: six in c:\users\user_\appdata\roaming\python\python38\site-packages (from Mastodon.py) (1.16.0)

Requirement already satisfied: requests>=2.4.2 in c:\users\user_\appdata\roaming\python\python38\site-packages (from Mastodon.py) (2.28.1)

Collecting blurhash>=1.1.4

Downloading blurhash-1.1.4-py2.py3-none-any.whl (5.3 kB)

Collecting python-magic

Downloading python_magic-0.4.27-py2.py3-none-any.whl (13 kB)

Requirement already satisfied: pytz in c:\users\user_\appdata\roaming\python\python38\site-packages (from Mastodon.py) (2022.4)

Requirement already satisfied: python-dateutil in c:\users\user_\appdata\roaming\python\python38\site-packages (from Mastodon.py) (2.8.2)

Requirement already satisfied: urllib3<1.27,>=1.21.1 in c:\users\user_\appdata\roaming\python\python38\site-packages (from requests>=2.4.2->Mastodon.py) (1.26.12)

Requirement already satisfied: idna<4,>=2.5 in c:\users\user_\appdata\roaming\python\python38\site-packages (from requests>=2.4.2->Mastodon.py) (3.4)

Requirement already satisfied: charset-normalizer<3,>=2 in c:\users\user_\appdata\roaming\python\python38\site-packages (from requests>=2.4.2->Mastodon.py) (2.1.1)

Requirement already satisfied: certifi>=2017.4.17 in c:\users\user_\appdata\roaming\python\python38\site-packages (from requests>=2.4.2->Mastodon.py) (2022.9.24)

Installing collected packages: blurhash, python-magic, Mastodon.py

Successfully installed Mastodon.py-1.7.0 blurhash-1.1.4 python-magic-0.4.27

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

今回はMastodon.pyのバージョン1.7.0をインストールしました。