Pythonは、バッチ更新ライブラリスクリプトに関するエラーを報告します。AttributeError:モジュール「pip」には属性「get_installed_distributions」がありません



Python Reports An Error About Batch Update Library Script



pipをバージョン10.0.0にアップグレードした後、以前はワンクリックですべてのライブラリをアップグレードできたスクリプトで、元のスクリプトの内容は次のとおりです。

#!/usr/bin/env python # -*- coding: utf-8 -*- ''' @Author : Soner @version : @Time : 2017/11/3/0003 15:11 @license : Copyright(C), Your Company ''' import pip from subprocess import call from time import sleep for dist in pip.get_installed_distributions(): # After execution, pip defaults to the Python3 version # Under the dual version, you need to update the Python2 version of the package, use py2 to run, and modify pip to pip2 call('pip install --upgrade ' + dist.project_name, shell=True)

現在は使用できず、次のエラーが表示されます。




後で、pipのファイルディレクトリを見つけて、ずっと検索しました。このモジュールがあります



通話レベルに応じて、調べて、

ソーススクリプトが変更された後、ワンクリック更新操作を正しく実行できます。

#!/usr/bin/env python # -*- coding: utf-8 -*- ''' @Author : Soner @version : @Time : 2017/11/3/0003 15:11 @license : Copyright(C), Your Company ''' import pip # pip V10.0.0 and above versions need to import the following packages from pip._internal.utils.misc import get_installed_distributions from subprocess import call from time import sleep for dist in get_installed_distributions(): # After execution, pip defaults to the Python3 version # Under the dual version, you need to update the Python2 version of the package, use py2 to run, and modify pip to pip2 call('pip install --upgrade ' + dist.project_name, shell=True) Xiaobai、バージョン10.0.0にアップグレードした直後にpipを呼び出せない理由がわかりません。素晴らしいガイドやより良い方法があれば、アドバイスしてください〜!