LoginSignup
4
1

More than 3 years have passed since last update.

【Python】pipでエラーが出た場合の対処(pyinstaller、pyautoguiなど)

Posted at

概要

久々に仮想環境作ってpipコマンドでpyinstallerをインストールしようとしたらエラーが出た。
多分、過去にpyautoguiで発生したエラーと同原因のもの。
 ↑ 【Python】pyautogui(PyMsgBox)インストールエラーに対する暫定対策
「wheel」をインストールしたら解決したのでメモ。

エラー内容

pipでpyinstallerをインストールすると、下記のようなエラー内容を吐いてインストールに失敗する。

(pyautogui_pillow) PS C:\Users\aaa\Desktop\python\10_右クリックツール> pip install pyinstaller        
Collecting pyinstaller
  Using cached pyinstaller-4.1.tar.gz (3.5 MB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
    Preparing wheel metadata ... error
    ERROR: Command errored out with exit status 1:

          :

    creating 'C:\Users\aaa\AppData\Local\Temp\pip-modern-metadata-f8yl8_co\pyinstaller.dist-info'
    error: invalid command 'bdist_wheel'
    ----------------------------------------
ERROR: Command errored out with exit status 1: 'c:\users\aaa\desktop\python\pyautogui_pillow\scripts\python.exe' 'c:\users\aaa\desktop\python\pyautogui_pillow\lib\site-packages\pip\_vendor\pep517\_in_process.py' prepare_metadata_for_build_wheel 'C:\Users\aaa\AppData\Local\Temp\tmpo72l8jp6' Check the logs for full command output.

下から3行目あたりのところでwheelの展開に失敗したと書いてあるので、この辺りが怪しい。

対処

pipでwheelをインストールするだけ。

> pip install wheel

あとはもう一度エラーが出ていたライブラリをpipでインストールし直せばよい。
とりあえずエラーが出ていた「pyinstaller」「pyautogui」はこの方法でインストールできた。

考察とか

wheel(ホイール)はpythonのパッケージング形式のひとつ。
かつてはeggがパッケージング形式の主流だったらしいが、現在は概ねwheelが使われているとのこと。
今回のケースは、ライブラリの最新ver.のパッケージング形式が変わり、既存の環境でwheelを展開できなくなったものと予想。
(私はpython環境を基本更新していないので、そういったところに根本原因があるのかもしれません)

ちなみに、pipエラーの要因にプロキシ起因やPC管理者権限起因で発生するものも多いそう。
社内LAN環境などで使用されている方はそちらも疑ってみてください。

環境

  • Windows10 Home
  • Python3.8.6(32bit)
  • Visual Studio Code 1.52.0
  • (venvコマンドで作成した仮想環境)
4
1
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
4
1