2
0

【Python】The 'pathlib' package is an obsolete backport of a standard library ・・・

Last updated at Posted at 2023-12-30

エラー状況

Anaconda Promptで以下のコマンドを実行し、Pythonによるデスクトップアプリケーションを実行形式のファイル(拡張子.exe)に変換しようと試みた。

Anacona Prompt
$conda install -c conda-forge pyinstalle
$pyinstaller Editor.py --noconsole --onefile

すると、以下のようなエラーが返ってきた。

The 'pathlib' package is an obsolete backport of a standard library package and is incompatible with PyInstaller. 
Please remove this package (located in C:\Users\user\anaconda3\Lib\site-packages) using conda remove
then try again.

Pythonに付随するpathlibパッケージが古すぎる(Pythonの標準ライブラリではない)ので、PyInstallerとの互換性がない。よって、それを削除した上で再度試してくださいとのこと。

対処法

エラーの言う通り、pathlibを削除してみる。

Anaconda Prompt
$conda remove pathlib

これを実行した上で再度、最初のコマンドを実行すると問題なく変換ができた。
また、この解決法以外に、以下のようにPyInstallerのバージョンをpathlibと互換性のあるバージョンまで下げるという方法もあるようだ(パッケージマネージャーにcondaではなく、pipを使用している点に注意)。

Anaconda Prompt
$pip install pyinstaller==5.1 

参考

久我涼子(2021) 『Pythonではじめるデスクトップアプリ開発入門』

2
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
0