Mac「brew install mysqlclient」でエラー「pip install mysql で成功」

環境

OS: macOS Big Sur バージョン 11.2.2
Python: Python 3.8.3

brew install mysqlclient でエラー

Python 仮想環境で「brew install mysqlclient」を実行したら下記のエラーが発生しました。結論から言うと「pip install mysqlclient」の間違いだったことに後で気づきました。

が、それに気づく前に「pip install mysql」を実行して無事解決したので書いておきます。

エラーログ

==> Searching for similarly named formulae...
These similarly named formulae were found:
mysql-client                                                                                  mysql-client@5.7
To install one of them, run (for example):
  brew install mysql-client
Error: No available formula or cask with the name "mysqlclient".
==> Searching for a previously deleted formula (in the last month)...
Error: No previously deleted formula found.
==> Searching taps on GitHub...
Error: No formulae found in taps.

とりあえず一番初めのエラー「Error: No available formula or cask with the name "mysqlclient".」が気になる。

調べてみると、「pip install mysql」を実行してその後に「pip install mysqlclient」を実行するという書き込みを発見。

ただ実際は「pip install mysql」だけで成功しました。

pip install mysql で成功

仮想環境内でコマンド「pip install mysql」を実行。

(venv) % pip install mysql
Collecting mysql
  Downloading https://files.pythonhosted.org/packages/bf/5f/b574ac9f70811df0540e403309f349a8b9fa1a25d3653824c32e52cc1f28/mysql-0.0.2.tar.gz
Collecting mysqlclient (from mysql)
  Downloading https://files.pythonhosted.org/packages/3c/df/59cd2fa5e48d0804d213bdcb1acb4d08c403b61c7ff7ed4dd4a6a2deb3f7/mysqlclient-2.0.3.tar.gz (88kB)
     |████████████████████████████████| 92kB 5.7MB/s 
Installing collected packages: mysqlclient, mysql
  Running setup.py install for mysqlclient ... done
  Running setup.py install for mysql ... done
Successfully installed mysql-0.0.2 mysqlclient-2.0.3
WARNING: You are using pip version 19.2.3, however version 21.0.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
(venv) %

「pip install mysql」で mysqlclient もカバーされている?

ログをみるとちらほら「mysqlclient」について書かれているのが見えると思います。

そして「Successfully installed mysql-0.0.2 mysqlclient-2.0.3」の一文も。これってストレートに「mysql と mysqlclient が無事インストールされました。」ってことですよね?

% pip install mysqlclient

なので python を立ち上げて「import MySQLdb」を実行してみたら特にエラーも出ず。

「pip install mysqlclient」を実行しても何も変わらず

ここまで来てやっと「brew install 〜」ではなく「pip install 〜」を実行すべきだったと気づいて「pip install mysqlclient」を実行してみましたが、すでに完了しているとのことで何も変わりませんでした。

(venv) % pip install mysqlclient
Requirement already satisfied: mysqlclient in /Users/ユーザー名/PythonProjects/sample_venv/lib/python3.8/site-packages (2.0.3)
(venv) %

Mac ローカルにインストールした MySQL を使う方法

MySQL を起動する

コマンド「brew services start mysql」でローカルの MySQL を起動します。

% brew services start mysql
==> Successfully started `mysql` (label: homebrew.mxcl.mysql)

MySQL に接続する

コマンド「mysql -u root」で MySQL に接続します。

% mysql -u root
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 9
Server version: 8.0.23 Homebrew

Copyright (c) 2000, 2021, Oracle and/or its affiliates.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql>

MySQL を遮断する

コマンド「exit」で MySQL のコマンドプロンプトから出ます。

mysql> exit
Bye

MySQL を終了する

コマンド「brew services stop mysql」で終了です。

% brew services stop mysql
==> Successfully stopped `mysql` (label: homebrew.mxcl.mysql)

【ログ】Ubuntu 20.04: systemctl start .socket & systemctl start .service

  • 実行コマンド:systemctl start ファイル名.socket, systemctl start ファイル名.service
  • 実行日:2021/04/10
  • 実行環境:Ubuntu 20.04
vpsadmin@xx1-234-56789:/etc/systemd/system$ systemctl start sample_django.socket
==== AUTHENTICATING FOR org.freedesktop.systemd1.manage-units ===
Authentication is required to start 'sample_django.socket'.
Multiple identities can be used for authentication:
 1.  ubuntu
 2.  ,,, (vpsadmin)
Choose identity to authenticate as (1-2): 2
Password: 
==== AUTHENTICATION COMPLETE ===
vpsadmin@xx1-234-56789:/etc/systemd/system$ systemctl start sample_django.service
==== AUTHENTICATING FOR org.freedesktop.systemd1.manage-units ===
Authentication is required to start 'sample_django.service'.
Multiple identities can be used for authentication:
 1.  ubuntu
 2.  ,,, (vpsadmin)
Choose identity to authenticate as (1-2): 2
Password: 
==== AUTHENTICATION COMPLETE ===
vpsadmin@xx1-234-56789:/etc/systemd/system$ systemctl start nginx
==== AUTHENTICATING FOR org.freedesktop.systemd1.manage-units ===
Authentication is required to start 'nginx.service'.
Multiple identities can be used for authentication:
 1.  ubuntu
 2.  ,,, (vpsadmin)
Choose identity to authenticate as (1-2): 2
Password: 
==== AUTHENTICATION COMPLETE ===
vpsadmin@xx1-234-56789:/etc/systemd/system$ systemctl enable nginx
Synchronizing state of nginx.service with SysV service script with /lib/systemd/systemd-sysv-install.
Executing: /lib/systemd/systemd-sysv-install enable nginx
==== AUTHENTICATING FOR org.freedesktop.systemd1.reload-daemon ===
Authentication is required to reload the systemd state.
Multiple identities can be used for authentication:
 1.  ubuntu
 2.  ,,, (vpsadmin)
Choose identity to authenticate as (1-2): 2
Password: 
==== AUTHENTICATION COMPLETE ===
==== AUTHENTICATING FOR org.freedesktop.systemd1.reload-daemon ===
Authentication is required to reload the systemd state.
Multiple identities can be used for authentication:
 1.  ubuntu
 2.  ,,, (vpsadmin)
Choose identity to authenticate as (1-2): 2
Password: 
==== AUTHENTICATION COMPLETE ===
==== AUTHENTICATING FOR org.freedesktop.systemd1.manage-unit-files ===
Authentication is required to manage system service or unit files.
Multiple identities can be used for authentication:
 1.  ubuntu
 2.  ,,, (vpsadmin)
Choose identity to authenticate as (1-2): 2
Password: 
==== AUTHENTICATION COMPLETE ===
==== AUTHENTICATING FOR org.freedesktop.systemd1.reload-daemon ===
Authentication is required to reload the systemd state.
Multiple identities can be used for authentication:
 1.  ubuntu
 2.  ,,, (vpsadmin)
Choose identity to authenticate as (1-2): 2
Password: 
==== AUTHENTICATION COMPLETE ===
vpsadmin@xx1-234-56789:/etc/systemd/system$ 

【ログ】Ubuntu 20.04: sudo apt install nginx

  • 実行コマンド:sudo apt install nginx
  • 実行日:2021/04/10
  • 実行環境:Ubuntu 20.04
vpsadmin@xx1-234-56789:~$ sudo apt install nginx
[sudo] password for vpsadmin: 
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following additional packages will be installed:
  fontconfig-config fonts-dejavu-core libfontconfig1 libgd3 libjbig0 libjpeg-turbo8 libjpeg8 libnginx-mod-http-image-filter libnginx-mod-http-xslt-filter
  libnginx-mod-mail libnginx-mod-stream libtiff5 libwebp6 libxpm4 nginx-common nginx-core
Suggested packages:
  libgd-tools fcgiwrap nginx-doc
The following NEW packages will be installed:
  fontconfig-config fonts-dejavu-core libfontconfig1 libgd3 libjbig0 libjpeg-turbo8 libjpeg8 libnginx-mod-http-image-filter libnginx-mod-http-xslt-filter
  libnginx-mod-mail libnginx-mod-stream libtiff5 libwebp6 libxpm4 nginx nginx-common nginx-core
0 upgraded, 17 newly installed, 0 to remove and 0 not upgraded.
Need to get 2431 kB of archives.
After this operation, 7891 kB of additional disk space will be used.
Do you want to continue? [Y/n] Y
Get:1 http://jp.archive.ubuntu.com/ubuntu focal/main amd64 fonts-dejavu-core all 2.37-1 [1041 kB]
Get:2 http://jp.archive.ubuntu.com/ubuntu focal/main amd64 fontconfig-config all 2.13.1-2ubuntu3 [28.8 kB]
Get:3 http://jp.archive.ubuntu.com/ubuntu focal/main amd64 libfontconfig1 amd64 2.13.1-2ubuntu3 [114 kB]
Get:4 http://jp.archive.ubuntu.com/ubuntu focal-updates/main amd64 libjpeg-turbo8 amd64 2.0.3-0ubuntu1.20.04.1 [117 kB]
Get:5 http://jp.archive.ubuntu.com/ubuntu focal/main amd64 libjpeg8 amd64 8c-2ubuntu8 [2194 B]
Get:6 http://jp.archive.ubuntu.com/ubuntu focal/main amd64 libjbig0 amd64 2.1-3.1build1 [26.7 kB]
Get:7 http://jp.archive.ubuntu.com/ubuntu focal/main amd64 libwebp6 amd64 0.6.1-2 [185 kB]
Get:8 http://jp.archive.ubuntu.com/ubuntu focal-updates/main amd64 libtiff5 amd64 4.1.0+git191117-2ubuntu0.20.04.1 [162 kB]
Get:9 http://jp.archive.ubuntu.com/ubuntu focal/main amd64 libxpm4 amd64 1:3.5.12-1 [34.0 kB]
Get:10 http://jp.archive.ubuntu.com/ubuntu focal/main amd64 libgd3 amd64 2.2.5-5.2ubuntu2 [118 kB]
Get:11 http://jp.archive.ubuntu.com/ubuntu focal-updates/main amd64 nginx-common all 1.18.0-0ubuntu1 [37.3 kB]
Get:12 http://jp.archive.ubuntu.com/ubuntu focal-updates/main amd64 libnginx-mod-http-image-filter amd64 1.18.0-0ubuntu1 [14.3 kB]
Get:13 http://jp.archive.ubuntu.com/ubuntu focal-updates/main amd64 libnginx-mod-http-xslt-filter amd64 1.18.0-0ubuntu1 [12.6 kB]
Get:14 http://jp.archive.ubuntu.com/ubuntu focal-updates/main amd64 libnginx-mod-mail amd64 1.18.0-0ubuntu1 [42.3 kB]
Get:15 http://jp.archive.ubuntu.com/ubuntu focal-updates/main amd64 libnginx-mod-stream amd64 1.18.0-0ubuntu1 [66.9 kB]
Get:16 http://jp.archive.ubuntu.com/ubuntu focal-updates/main amd64 nginx-core amd64 1.18.0-0ubuntu1 [425 kB]
Get:17 http://jp.archive.ubuntu.com/ubuntu focal-updates/main amd64 nginx all 1.18.0-0ubuntu1 [3624 B]
Fetched 2431 kB in 0s (6480 kB/s)
Preconfiguring packages ...
Selecting previously unselected package fonts-dejavu-core.
(Reading database ... 115179 files and directories currently installed.)
Preparing to unpack .../00-fonts-dejavu-core_2.37-1_all.deb ...
Unpacking fonts-dejavu-core (2.37-1) ...
Selecting previously unselected package fontconfig-config.
Preparing to unpack .../01-fontconfig-config_2.13.1-2ubuntu3_all.deb ...
Unpacking fontconfig-config (2.13.1-2ubuntu3) ...
Selecting previously unselected package libfontconfig1:amd64.
Preparing to unpack .../02-libfontconfig1_2.13.1-2ubuntu3_amd64.deb ...
Unpacking libfontconfig1:amd64 (2.13.1-2ubuntu3) ...
Selecting previously unselected package libjpeg-turbo8:amd64.
Preparing to unpack .../03-libjpeg-turbo8_2.0.3-0ubuntu1.20.04.1_amd64.deb ...
Unpacking libjpeg-turbo8:amd64 (2.0.3-0ubuntu1.20.04.1) ...
Selecting previously unselected package libjpeg8:amd64.
Preparing to unpack .../04-libjpeg8_8c-2ubuntu8_amd64.deb ...
Unpacking libjpeg8:amd64 (8c-2ubuntu8) ...
Selecting previously unselected package libjbig0:amd64.
Preparing to unpack .../05-libjbig0_2.1-3.1build1_amd64.deb ...
Unpacking libjbig0:amd64 (2.1-3.1build1) ...
Selecting previously unselected package libwebp6:amd64.
Preparing to unpack .../06-libwebp6_0.6.1-2_amd64.deb ...
Unpacking libwebp6:amd64 (0.6.1-2) ...
Selecting previously unselected package libtiff5:amd64.
Preparing to unpack .../07-libtiff5_4.1.0+git191117-2ubuntu0.20.04.1_amd64.deb ...
Unpacking libtiff5:amd64 (4.1.0+git191117-2ubuntu0.20.04.1) ...
Selecting previously unselected package libxpm4:amd64.
Preparing to unpack .../08-libxpm4_1%3a3.5.12-1_amd64.deb ...
Unpacking libxpm4:amd64 (1:3.5.12-1) ...
Selecting previously unselected package libgd3:amd64.
Preparing to unpack .../09-libgd3_2.2.5-5.2ubuntu2_amd64.deb ...
Unpacking libgd3:amd64 (2.2.5-5.2ubuntu2) ...
Selecting previously unselected package nginx-common.
Preparing to unpack .../10-nginx-common_1.18.0-0ubuntu1_all.deb ...
Unpacking nginx-common (1.18.0-0ubuntu1) ...
Selecting previously unselected package libnginx-mod-http-image-filter.
Preparing to unpack .../11-libnginx-mod-http-image-filter_1.18.0-0ubuntu1_amd64.deb ...
Unpacking libnginx-mod-http-image-filter (1.18.0-0ubuntu1) ...
Selecting previously unselected package libnginx-mod-http-xslt-filter.
Preparing to unpack .../12-libnginx-mod-http-xslt-filter_1.18.0-0ubuntu1_amd64.deb ...
Unpacking libnginx-mod-http-xslt-filter (1.18.0-0ubuntu1) ...
Selecting previously unselected package libnginx-mod-mail.
Preparing to unpack .../13-libnginx-mod-mail_1.18.0-0ubuntu1_amd64.deb ...
Unpacking libnginx-mod-mail (1.18.0-0ubuntu1) ...
Selecting previously unselected package libnginx-mod-stream.
Preparing to unpack .../14-libnginx-mod-stream_1.18.0-0ubuntu1_amd64.deb ...
Unpacking libnginx-mod-stream (1.18.0-0ubuntu1) ...
Selecting previously unselected package nginx-core.
Preparing to unpack .../15-nginx-core_1.18.0-0ubuntu1_amd64.deb ...
Unpacking nginx-core (1.18.0-0ubuntu1) ...
Selecting previously unselected package nginx.
Preparing to unpack .../16-nginx_1.18.0-0ubuntu1_all.deb ...
Unpacking nginx (1.18.0-0ubuntu1) ...
Setting up libxpm4:amd64 (1:3.5.12-1) ...
Setting up nginx-common (1.18.0-0ubuntu1) ...
Created symlink /etc/systemd/system/multi-user.target.wants/nginx.service → /lib/systemd/system/nginx.service.
Setting up libjbig0:amd64 (2.1-3.1build1) ...
Setting up libnginx-mod-http-xslt-filter (1.18.0-0ubuntu1) ...
Setting up libwebp6:amd64 (0.6.1-2) ...
Setting up fonts-dejavu-core (2.37-1) ...
Setting up libjpeg-turbo8:amd64 (2.0.3-0ubuntu1.20.04.1) ...
Setting up libjpeg8:amd64 (8c-2ubuntu8) ...
Setting up libnginx-mod-mail (1.18.0-0ubuntu1) ...
Setting up fontconfig-config (2.13.1-2ubuntu3) ...
Setting up libnginx-mod-stream (1.18.0-0ubuntu1) ...
Setting up libtiff5:amd64 (4.1.0+git191117-2ubuntu0.20.04.1) ...
Setting up libfontconfig1:amd64 (2.13.1-2ubuntu3) ...
Setting up libgd3:amd64 (2.2.5-5.2ubuntu2) ...
Setting up libnginx-mod-http-image-filter (1.18.0-0ubuntu1) ...
Setting up nginx-core (1.18.0-0ubuntu1) ...
Setting up nginx (1.18.0-0ubuntu1) ...
Processing triggers for ufw (0.36-6) ...
Processing triggers for systemd (245.4-4ubuntu3.6) ...
Processing triggers for man-db (2.9.1-1) ...
Processing triggers for libc-bin (2.31-0ubuntu9.2) ...
vpsadmin@xx1-234-56789:~$ 

【ログ】Ubuntu20.04: sudo apt install python3.9-dev

  • 実行コマンド:sudo apt install python3.9-dev
  • 実行日:2021/04/10
  • 実行環境:Ubuntu 20.04
vpsadmin@xx1-234-56789:~$ sudo apt install python3.9-dev
[sudo] password for vpsadmin: 
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following additional packages will be installed:
  libpython3.9 libpython3.9-dev
The following NEW packages will be installed:
  libpython3.9 libpython3.9-dev python3.9-dev
0 upgraded, 3 newly installed, 0 to remove and 0 not upgraded.
Need to get 6342 kB of archives.
After this operation, 27.2 MB of additional disk space will be used.
Do you want to continue? [Y/n] Y
Get:1 http://jp.archive.ubuntu.com/ubuntu focal-updates/universe amd64 libpython3.9 amd64 3.9.0-5~20.04 [1710 kB]
Get:2 http://jp.archive.ubuntu.com/ubuntu focal-updates/universe amd64 libpython3.9-dev amd64 3.9.0-5~20.04 [4119 kB]
Get:3 http://jp.archive.ubuntu.com/ubuntu focal-updates/universe amd64 python3.9-dev amd64 3.9.0-5~20.04 [512 kB]
Fetched 6342 kB in 1s (4552 kB/s)  
Selecting previously unselected package libpython3.9:amd64.
(Reading database ... 114984 files and directories currently installed.)
Preparing to unpack .../libpython3.9_3.9.0-5~20.04_amd64.deb ...
Unpacking libpython3.9:amd64 (3.9.0-5~20.04) ...
Selecting previously unselected package libpython3.9-dev:amd64.
Preparing to unpack .../libpython3.9-dev_3.9.0-5~20.04_amd64.deb ...
Unpacking libpython3.9-dev:amd64 (3.9.0-5~20.04) ...
Selecting previously unselected package python3.9-dev.
Preparing to unpack .../python3.9-dev_3.9.0-5~20.04_amd64.deb ...
Unpacking python3.9-dev (3.9.0-5~20.04) ...
Setting up libpython3.9:amd64 (3.9.0-5~20.04) ...
Setting up libpython3.9-dev:amd64 (3.9.0-5~20.04) ...
Setting up python3.9-dev (3.9.0-5~20.04) ...
Processing triggers for man-db (2.9.1-1) ...
Processing triggers for libc-bin (2.31-0ubuntu9.2) ...
vpsadmin@xx1-234-56789:~$

【ログ】Ubuntu 20.04: sudo apt install python3-pip python3.9-venv

  • 実行コマンド:sudo apt install python3-pip python3.9-venv
  • 実行日:2021/04/10
  • 実行環境:Ubuntu 20.04
vpsadmin@xx1-234-56789:~$ sudo apt install python3-pip python3.9-venv
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following additional packages will be installed:
  libexpat1-dev libpython3-dev libpython3.8-dev python-pip-whl python3-dev python3-wheel python3.8-dev
The following NEW packages will be installed:
  libexpat1-dev libpython3-dev libpython3.8-dev python-pip-whl python3-dev python3-pip python3-wheel python3.8-dev
  python3.9-venv
0 upgraded, 9 newly installed, 0 to remove and 0 not upgraded.
Need to get 6640 kB of archives.
After this operation, 24.9 MB of additional disk space will be used.
Do you want to continue? [Y/n] Y
Get:1 http://jp.archive.ubuntu.com/ubuntu focal/main amd64 libexpat1-dev amd64 2.2.9-1build1 [116 kB]
Get:2 http://jp.archive.ubuntu.com/ubuntu focal-updates/main amd64 libpython3.8-dev amd64 3.8.5-1~20.04.2 [3942 kB]
Get:3 http://jp.archive.ubuntu.com/ubuntu focal/main amd64 libpython3-dev amd64 3.8.2-0ubuntu2 [7236 B]
Get:4 http://jp.archive.ubuntu.com/ubuntu focal-updates/universe amd64 python-pip-whl all 20.0.2-5ubuntu1.1 [1799 kB]
Get:5 http://jp.archive.ubuntu.com/ubuntu focal-updates/main amd64 python3.8-dev amd64 3.8.5-1~20.04.2 [515 kB]
Get:6 http://jp.archive.ubuntu.com/ubuntu focal/main amd64 python3-dev amd64 3.8.2-0ubuntu2 [1212 B]
Get:7 http://jp.archive.ubuntu.com/ubuntu focal/universe amd64 python3-wheel all 0.34.2-1 [23.8 kB]
Get:8 http://jp.archive.ubuntu.com/ubuntu focal-updates/universe amd64 python3-pip all 20.0.2-5ubuntu1.1 [230 kB]
Get:9 http://jp.archive.ubuntu.com/ubuntu focal-updates/universe amd64 python3.9-venv amd64 3.9.0-5~20.04 [5444 B]
Fetched 6640 kB in 1s (4528 kB/s)   
Selecting previously unselected package libexpat1-dev:amd64.
(Reading database ... 114470 files and directories currently installed.)
Preparing to unpack .../0-libexpat1-dev_2.2.9-1build1_amd64.deb ...
Unpacking libexpat1-dev:amd64 (2.2.9-1build1) ...
Selecting previously unselected package libpython3.8-dev:amd64.
Preparing to unpack .../1-libpython3.8-dev_3.8.5-1~20.04.2_amd64.deb ...
Unpacking libpython3.8-dev:amd64 (3.8.5-1~20.04.2) ...
Selecting previously unselected package libpython3-dev:amd64.
Preparing to unpack .../2-libpython3-dev_3.8.2-0ubuntu2_amd64.deb ...
Unpacking libpython3-dev:amd64 (3.8.2-0ubuntu2) ...
Selecting previously unselected package python-pip-whl.
Preparing to unpack .../3-python-pip-whl_20.0.2-5ubuntu1.1_all.deb ...
Unpacking python-pip-whl (20.0.2-5ubuntu1.1) ...
Selecting previously unselected package python3.8-dev.
Preparing to unpack .../4-python3.8-dev_3.8.5-1~20.04.2_amd64.deb ...
Unpacking python3.8-dev (3.8.5-1~20.04.2) ...
Selecting previously unselected package python3-dev.
Preparing to unpack .../5-python3-dev_3.8.2-0ubuntu2_amd64.deb ...
Unpacking python3-dev (3.8.2-0ubuntu2) ...
Selecting previously unselected package python3-wheel.
Preparing to unpack .../6-python3-wheel_0.34.2-1_all.deb ...
Unpacking python3-wheel (0.34.2-1) ...
Selecting previously unselected package python3-pip.
Preparing to unpack .../7-python3-pip_20.0.2-5ubuntu1.1_all.deb ...
Unpacking python3-pip (20.0.2-5ubuntu1.1) ...
Selecting previously unselected package python3.9-venv.
Preparing to unpack .../8-python3.9-venv_3.9.0-5~20.04_amd64.deb ...
Unpacking python3.9-venv (3.9.0-5~20.04) ...
Setting up python3-wheel (0.34.2-1) ...
Setting up libexpat1-dev:amd64 (2.2.9-1build1) ...
Setting up libpython3.8-dev:amd64 (3.8.5-1~20.04.2) ...
Setting up python3.8-dev (3.8.5-1~20.04.2) ...
Setting up python-pip-whl (20.0.2-5ubuntu1.1) ...
Setting up python3.9-venv (3.9.0-5~20.04) ...
Setting up libpython3-dev:amd64 (3.8.2-0ubuntu2) ...
Setting up python3-dev (3.8.2-0ubuntu2) ...
Setting up python3-pip (20.0.2-5ubuntu1.1) ...
Processing triggers for man-db (2.9.1-1) ...
vpsadmin@xx1-234-56789:~$ 

【ログ】Ubuntu 20.04: sudo apt install vsftpd

  • 実行コマンド:sudo apt install vsftpd
  • 実行日:2021/04/10
  • 実行環境:Ubuntu 20.04
vpsadmin@xx1-234-56789:~$ sudo apt install vsftpd
[sudo] password for vpsadmin: 
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following additional packages will be installed:
  ssl-cert
Suggested packages:
  openssl-blacklist
The following NEW packages will be installed:
  ssl-cert vsftpd
0 upgraded, 2 newly installed, 0 to remove and 0 not upgraded.
Need to get 132 kB of archives.
After this operation, 402 kB of additional disk space will be used.
Do you want to continue? [Y/n] Y
Get:1 http://jp.archive.ubuntu.com/ubuntu focal/main amd64 ssl-cert all 1.0.39 [17.0 kB]
Get:2 http://jp.archive.ubuntu.com/ubuntu focal/main amd64 vsftpd amd64 3.0.3-12 [115 kB]
Fetched 132 kB in 0s (779 kB/s)
Preconfiguring packages ...
Selecting previously unselected package ssl-cert.
(Reading database ... 107011 files and directories currently installed.)
Preparing to unpack .../ssl-cert_1.0.39_all.deb ...
Unpacking ssl-cert (1.0.39) ...
Selecting previously unselected package vsftpd.
Preparing to unpack .../vsftpd_3.0.3-12_amd64.deb ...
Unpacking vsftpd (3.0.3-12) ...
Setting up ssl-cert (1.0.39) ...
Setting up vsftpd (3.0.3-12) ...
Created symlink /etc/systemd/system/multi-user.target.wants/vsftpd.service → /lib/systemd/system/vsftpd.service.
Processing triggers for man-db (2.9.1-1) ...
Processing triggers for systemd (245.4-4ubuntu3.6) ...
vpsadmin@xx1-234-56789:~$ 

【エラー】Add correct host key in .ssh/known_hosts to get rid of this message.

環境

OS: macOS Catalina バージョン 10.15.4

エラー発生

さくらの VPS で OS をインストールしなおした後、ssh で接続しようとしたら下記の警告が表示され接続できない状態になりました。

% ssh ubuntu@xx1-234-56789.vs.sakura.ne.jp  
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@    WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!     @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY!
Someone could be eavesdropping on you right now (man-in-the-middle attack)!
It is also possible that a host key has just been changed.
The fingerprint for the ECDSA key sent by the remote host is
QWE123:QWertYU1234567asDfghJklzXCvbNm.
Please contact your system administrator.
Add correct host key in /Users/ユーザー名/.ssh/known_hosts to get rid of this message.
Offending ECDSA key in /Users/ユーザー名/.ssh/known_hosts:2
ECDSA host key for xx1-234-56789.vs.sakura.ne.jp has changed and you have requested strict checking.
Host key verification failed.
%

要件

「Add correct host key in /Users/ユーザー名/.ssh/known_hosts to get rid of this message.」

日本語訳

「このメッセージを非表示にするために /Users/ユーザー名/.ssh/known_hosts に正しいキーを追加してください。」

解決方法

ローカル環境の「.ssh」ディレクトリ(?)へ cd で移動します。

 /Users % cd ユーザー名
% cd .ssh

「.ssh」内でコマンド「ssh-keygen -R サーバーのIPアドレス」を実行します。

 .ssh % ssh-keygen -R 123.456.78.90
# Host 133.125.39.81 found: line 2
/Users/ユーザー名/.ssh/known_hosts updated.
Original contents retained as /Users/ユーザー名/.ssh/known_hosts.old
 .ssh %

更新された模様。ssh で接続できる様になりました。

% ssh ubuntu@xx1-234-56789.vs.sakura.ne.jp  
The authenticity of host 'xx1-234-56789.vs.sakura.ne.jp (123.456.78.90)' can't be established.
ECDSA key fingerprint is ABC123:QWERTYUIOPASDFGHJKLZXCVBNM.
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Warning: Permanently added 'xx1-234-56789.vs.sakura.ne.jp,123.456.78.90' (ECDSA) to the list of known hosts.
ubuntu@xx1-234-56789.vs.sakura.ne.jp's password: 
Welcome to Ubuntu 20.04.1 LTS (GNU/Linux 5.4.0-52-generic x86_64)

【ログ】Ubuntu 20.04: sudo apt install python3.9-dev

  • 実行コマンド:sudo apt install python3.9-dev
  • 実行日:2021/04/09
  • 実行環境:Ubuntu 20.04
adminvps@xx1-234-567890:~$ sudo apt install python3.9-dev
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following additional packages will be installed:
  libpython3.9 libpython3.9-dev
The following NEW packages will be installed:
  libpython3.9 libpython3.9-dev python3.9-dev
0 upgraded, 3 newly installed, 0 to remove and 0 not upgraded.
Need to get 6342 kB of archives.
After this operation, 27.2 MB of additional disk space will be used.
Do you want to continue? [Y/n] Y
Get:1 http://jp.archive.ubuntu.com/ubuntu focal-updates/universe amd64 libpython3.9 amd64 3.9.0-5~20.04 [1710 kB]
Get:2 http://jp.archive.ubuntu.com/ubuntu focal-updates/universe amd64 libpython3.9-dev amd64 3.9.0-5~20.04 [4119 kB]
Get:3 http://jp.archive.ubuntu.com/ubuntu focal-updates/universe amd64 python3.9-dev amd64 3.9.0-5~20.04 [512 kB]
Fetched 6342 kB in 1s (4493 kB/s)      
Selecting previously unselected package libpython3.9:amd64.
(Reading database ... 114984 files and directories currently installed.)
Preparing to unpack .../libpython3.9_3.9.0-5~20.04_amd64.deb ...
Unpacking libpython3.9:amd64 (3.9.0-5~20.04) ...
Selecting previously unselected package libpython3.9-dev:amd64.
Preparing to unpack .../libpython3.9-dev_3.9.0-5~20.04_amd64.deb ...
Unpacking libpython3.9-dev:amd64 (3.9.0-5~20.04) ...
Selecting previously unselected package python3.9-dev.
Preparing to unpack .../python3.9-dev_3.9.0-5~20.04_amd64.deb ...
Unpacking python3.9-dev (3.9.0-5~20.04) ...
Setting up libpython3.9:amd64 (3.9.0-5~20.04) ...
Setting up libpython3.9-dev:amd64 (3.9.0-5~20.04) ...
Setting up python3.9-dev (3.9.0-5~20.04) ...
Processing triggers for man-db (2.9.1-1) ...
Processing triggers for libc-bin (2.31-0ubuntu9.2) ...
adminvps@xx1-234-567890:~/sample/bin$ 

【ログ】Ubuntu 20.04: sudo apt-get install python3.9-venv

  • 実行コマンド:sudo apt-get install python3.9-venv
  • 実行日:2021/04/09
  • 実行環境:Ubuntu 20.04
adminvps@xx1-234-56789:~$ sudo apt-get install python3.9-venv
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following NEW packages will be installed:
  python3.9-venv
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 5444 B of archives.
After this operation, 27.6 kB of additional disk space will be used.
Get:1 http://jp.archive.ubuntu.com/ubuntu focal-updates/universe amd64 python3.9-venv amd64 3.9.0-5~20.04 [5444 B]
Fetched 5444 B in 1s (7366 B/s)          
Selecting previously unselected package python3.9-venv.
(Reading database ... 114978 files and directories currently installed.)
Preparing to unpack .../python3.9-venv_3.9.0-5~20.04_amd64.deb ...
Unpacking python3.9-venv (3.9.0-5~20.04) ...
Setting up python3.9-venv (3.9.0-5~20.04) ...
adminvps@xx1-234-56789:~$