FreeBSD - メンテナンス・トラブルシュート - Python - python3.9 → python3.11

 クラウディア
1. 概要
2. 確認
3. 掃除
4. /etc/make.conf 編集
5. アップグレード
6. 依存パッケージ
7. 本来の目的は

1. 概要

 2023年10月31日のことです。  特に促されてはいないものの、別途、問題も発生しているので、ついでに、「python」のバージョンをあげようと思った次第です。  で、現在の「python」のバージョンをみてみると

$ python --version
Python 3.9.18
 巷(ちまた)では、「4.0」が出ているらしいが、「port」は、2023年10月31日時点で、「3.11」が最新なので・・・。  「python3.11」へアップグレードしようと思います。

2. 確認

 「python」関連をどれくらいインストールしているかを見てみます。

$ pkg version -v | grep py
py39-Babel-2.13.1                  =   up-to-date with index
py39-CommonMark-0.9.1              =   up-to-date with index
py39-Jinja2-3.1.2                  =   up-to-date with index
py39-acme-2.6.0,1                  =   up-to-date with index
py39-alabaster-0.7.13              =   up-to-date with index
py39-appdirs-1.4.4                 =   up-to-date with index
py39-beaker-1.12.1                 =   up-to-date with index
py39-beautifulsoup-4.12.2          =   up-to-date with index
py39-build-0.10.0_2                =   up-to-date with index
py39-calver-2022.6.26_1            =   up-to-date with index
py39-certifi-2023.7.22             =   up-to-date with index
py39-cffi-1.16.0                   =   up-to-date with index
py39-charset-normalizer-3.3.0      =   up-to-date with index
py39-click-8.1.3                   =   up-to-date with index
py39-click-default-group-1.2.4     =   up-to-date with index
py39-configargparse-1.5.3          =   up-to-date with index
py39-configobj-5.0.8               =   up-to-date with index
py39-country-22.3.5                =   up-to-date with index
py39-cryptography-41.0.4_1,1       =   up-to-date with index
py39-cython-0.29.36                =   up-to-date with index
py39-distro-1.8.0_2                =   up-to-date with index
py39-docutils-0.19,1               =   up-to-date with index
py39-editables-0.5                 =   up-to-date with index
py39-evdev-1.6.0                   =   up-to-date with index
py39-flit-3.9.0                    =   up-to-date with index
py39-flit-core-3.9.0               =   up-to-date with index
py39-furo-2023.7.26                =   up-to-date with index
py39-future-0.18.3                 =   up-to-date with index
py39-gi-docgen-2022.2              =   up-to-date with index
py39-google-i18n-address-3.1.0     =   up-to-date with index
py39-hatch-vcs-0.3.0_2             =   up-to-date with index
py39-hatchling-1.18.0              =   up-to-date with index
py39-html5lib-1.1                  =   up-to-date with index
py39-idna-3.4_1                    =   up-to-date with index
py39-imagesize-1.4.1               =   up-to-date with index
py39-importlib-metadata-6.8.0      =   up-to-date with index
py39-incremental-21.3.0            =   up-to-date with index
py39-installer-0.7.0               =   up-to-date with index
py39-intervaltree-3.1.0            =   up-to-date with index
py39-josepy-1.13.0                 =   up-to-date with index
py39-json5-0.9.11                  =   up-to-date with index
py39-libxml2-2.10.4                =   up-to-date with index
py39-lxml-4.9.3                    =   up-to-date with index
py39-mako-1.2.4                    =   up-to-date with index
py39-markdown-3.3.7_1              =   up-to-date with index
py39-markdown-it-py-3.0.0          =   up-to-date with index
py39-markupsafe-2.1.3              =   up-to-date with index
py39-mdit-py-plugins-0.4.0         =   up-to-date with index
py39-mdurl-0.1.2_2                 =   up-to-date with index
py39-myst-parser-2.0.0             =   up-to-date with index
py39-olefile-0.46                  =   up-to-date with index
py39-openssl-23.2.0,1              =   up-to-date with index
py39-packaging-23.2                =   up-to-date with index
py39-parsedatetime-2.6             =   up-to-date with index
py39-pathspec-0.11.2               =   up-to-date with index
py39-pillow-10.1.0                 =   up-to-date with index
py39-pip-23.3                      =   up-to-date with index
py39-platformdirs-3.11.0           =   up-to-date with index
py39-pluggy-1.3.0                  =   up-to-date with index
py39-ply-3.11                      =   up-to-date with index
py39-psycopg2-2.9.9                =   up-to-date with index
py39-pycparser-2.21                =   up-to-date with index
py39-pygments-2.16.1               =   up-to-date with index
py39-pyparsing-3.1.1               =   up-to-date with index
py39-pyproject_hooks-1.0.0_2       =   up-to-date with index
py39-pyrfc3339-1.1                 =   up-to-date with index
py39-pysocks-1.7.1                 =   up-to-date with index
py39-pystemmer-2.0.1               =   up-to-date with index
py39-python-augeas-1.0.3           =   up-to-date with index
py39-pytz-2023.3,1                 =   up-to-date with index
py39-pyudev-0.22.0                 =   up-to-date with index
py39-recommonmark-0.5.0_2          =   up-to-date with index
py39-repoze.sphinx.autointerface-0.8 =   up-to-date with index
py39-requests-2.31.0               =   up-to-date with index
py39-requests-toolbelt-1.0.0       =   up-to-date with index
py39-semantic-version-2.10.0       =   up-to-date with index
py39-setuptools-63.1.0_1           =   up-to-date with index
py39-setuptools-rust-1.7.0         =   up-to-date with index
py39-setuptools_scm-6.4.2          =   up-to-date with index
py39-setuptools_scm_git_archive-1.4 =   up-to-date with index
py39-six-1.16.0                    =   up-to-date with index
py39-smartypants-2.0.1             =   up-to-date with index
py39-snowballstemmer-2.2.0         =   up-to-date with index
py39-sortedcontainers-2.4.0        =   up-to-date with index
py39-soupsieve-2.0.1               =   up-to-date with index
py39-sphinx-5.3.0_1,1              =   up-to-date with index
py39-sphinx-basic-ng-1.0.0b2       =   up-to-date with index
py39-sphinx-copybutton-0.5.2       =   up-to-date with index
py39-sphinx-inline-tabs-2023.4.21  =   up-to-date with index
py39-sphinx-markdown-tables-0.0.15,1 =   up-to-date with index
py39-sphinx_rtd_theme-1.0.0        =   up-to-date with index
py39-sphinxcontrib-applehelp-1.0.2 =   up-to-date with index
py39-sphinxcontrib-devhelp-1.0.2   =   up-to-date with index
py39-sphinxcontrib-htmlhelp-2.0.0  =   up-to-date with index
py39-sphinxcontrib-jsmath-1.0.1    =   up-to-date with index
py39-sphinxcontrib-qthelp-1.0.3    =   up-to-date with index
py39-sphinxcontrib-serializinghtml-1.1.5 =   up-to-date with index
py39-sphinxcontrib-towncrier-0.3.2a0_1 =   up-to-date with index
py39-tkinter-3.9.18_7              =   up-to-date with index
py39-toml-0.10.2                   =   up-to-date with index
py39-tomli-2.0.1_2                 =   up-to-date with index
py39-tomli-w-1.0.0_2               =   up-to-date with index
py39-towncrier-22.12.0_1           =   up-to-date with index
py39-trove-classifiers-2023.9.19   =   up-to-date with index
py39-typing-extensions-4.8.0       =   up-to-date with index
py39-typogrify-2.0.7               =   up-to-date with index
py39-urllib3-1.26.17,1             =   up-to-date with index
py39-wcwidth-0.2.8                 =   up-to-date with index
py39-webencodings-0.5.1            =   up-to-date with index
py39-wheel-0.41.3                  =   up-to-date with index
py39-xml2rfc-3.18.2                =   up-to-date with index
py39-yaml-6.0                      =   up-to-date with index
py39-zipp-3.17.0                   =   up-to-date with index
py39-zope.component-4.2.2          =   up-to-date with index
py39-zope.event-4.1.0              =   up-to-date with index
py39-zope.interface-5.3.0          =   up-to-date with index
python38-3.8.18                    =   up-to-date with index
python39-3.9.18                    =   up-to-date with index
scons-py39-4.4.0                   =   up-to-date with index
 うはぁ、これをもれなくアップグレードね。  とうとう、「python27」は、なくなったようです。  「python37」は、以前、明示的に削除しましたからね。

3. 掃除

 ここから、いつも手戻りが発生しますが・・・今回はどうかな?  まず、今までの経験上で。

vi /etc/make.conf
 下記を削除して。

DEFAULT_VERSIONS+=python=3.9 python3=3.9
 掃除。

cd /usr/ports/lang/python3
make deinstall clean

4. /etc/make.conf 編集


vi /etc/make.conf
 前項で削除した

DEFAULT_VERSIONS+=python=3.9 python3=3.9
 の代わりに下記を記述します。

DEFAULT_VERSIONS+=python=3.11 python3=3.11

5. アップグレード


portupgrade -f python39 -o lang/python311

pkg set -o lang/python39:lang/python311
 2つ目のコマンドは

Change origin from lang/python39 to lang/python311 for python39-3.9.18? [y/N]:
 ときいてきますので、y Enter で応えます。  「make」と「install」。

cd /usr/ports/lang/python311
make deinstall clean
make
make install
 もう一回。

portupgrade -rR python
 シンボリックリンクは、はりなおします。  「root」ユーザ権限で。

rm /usr/local/bin/python
ln -s /usr/local/bin/python3.11 /usr/local/bin/python
 ログインユーザで確認します。

$ python --version
Python 3.11.6
 パッケージの状況を確認します。

$ pkg version -v | grep python
py39-python-augeas-1.0.3           =   up-to-date with index
python311-3.11.6                   =   up-to-date with index
python38-3.8.18                    =   up-to-date with index
python39-3.9.18                    =   up-to-date with index

6. 依存パッケージ

 後は、他のパッケージのアップグレードの際、競合や衝突が発生する都度、対処していくしかないかな・・・。

$ pkg version -v | grep py37

$ pkg version -v | grep py38
 上記2つは、ありませんでした。  下記は、まぁ、最初に「py」で計算したときの「py39」分がそのまま。  結構ありますな。

$ pkg version -v | grep py39
 とりあえず、「pip」からだな。

pkg delete py39-pip
 これは、単体でしたので、y で削除して、インストールします。

cd /usr/ports/devel/py-pip
make
 これが、「make」の時点で。

pkg-static: py311-build-0.10.0_2 conflicts with py39-build-0.10.0_2 (installs files into the same place).  Problematic file: /usr/local/bin/pyproject-build
*** Error code 1

Stop.
make[6]: stopped in /usr/ports/devel/py-build
*** Error code 1

Stop.
make[5]: stopped in /usr/ports/devel/py-editables
*** Error code 1

Stop.
make[4]: stopped in /usr/ports/devel/py-hatchling
*** Error code 1

Stop.
make[3]: stopped in /usr/ports/www/py-beautifulsoup
*** Error code 1

Stop.
make[2]: stopped in /usr/ports/textproc/py-furo
*** Error code 1

Stop.
make[1]: stopped in /usr/ports/devel/py-pip
*** Error code 1

Stop.
make: stopped in /usr/ports/devel/py-pip
 うむぅ、ちゅうことで。

pkg delete py39-furo
pkg delete py39-beautifulsoup
pkg delete py39-hatchling
pkg delete py39-editables
pkg delete py39-build
 上記は、依存するものもありましたが、それも「py39」軍団だったので、全部 y で削除して、だいじょうぶです。  以降、同様の調子で、削除して。

pkg delete py39-wheel
pkg delete py39-pluggy
pkg delete py39-lxml
pkg delete py39-cython
 他にもありますが、「py-pip」が通るまでやります。  必要なものがあれば、随時・・・。

7. 本来の目的は

 今回の本来の目的は、「certbot」がエラーになるのを解消することだったのですが・・・。  「py-acme」「py-certbot」が依存するものを削除しながら、アップグレードが通るまでやりました。  そして、「certbot」が、「python3.11」で動作するようになったものの・・・。  やはり、こけるのです。  いやはや、困った、証明書の有効期限が切れるまでに、「ports」が更新されるだろうか・・・?  と思っていあたら、2023年11月6日、別の方法で「certbot」の問題は解決しました。  それについては、前ページで。
AbemaTV 無料体験
5G CONNECT
earthcar(アースカー)
ハイスピードプラン