I am trying to install a list of packages using pip.
The code I use is:
import pip
def install(package_name):
try:
pip.main(['install', package_name])
except:
print("Unable to install " + package_name)
This code works fine, and if the package is not available, it gives an error:
No matching distributions found
However, what I am trying to do is if the installation fails (for example, an invalid package name), I want to print the failed package.
What can be done for this?
Any help would be appreciated, thanks.
Gokul source
share