Nag-uulat ang python ng isang error tungkol sa script sa pag-update ng batch ng library:

Python Reports An Error About Batch Update Library Script



Matapos ang pag-upgrade ng pip sa bersyon 10.0.0, ang script na nagawang mag-upgrade ng lahat ng mga aklatan sa isang pag-click dati, ang orihinal na nilalaman ng script ay ang mga sumusunod:

#!/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)

Hindi ito maaaring gamitin ngayon, at na-prompt ang sumusunod na error:






Nang maglaon, natagpuan ko ang direktoryo ng file ng pip, hinanap sa lahat ng paraan, mayroong module na ito



Ayon sa antas ng tawag, tumingin,

Matapos mabago ang pinagmulang script, maisasagawa nang wasto ang isang operasyon na pag-update ng update:

#!/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, hindi ko alam kung bakit hindi maaaring tawagan nang direkta ang pip pagkatapos mag-upgrade sa bersyon 10.0.0. Kung mayroong isang mahusay na gabay o isang mas mahusay na paraan, mangyaring payuhan ~!