I saw an older question, suggesting to use pip.main(package), however this does not upgrade a package. I could not find anything. Thanks in advance.
1 Answer
Try pip.main(['install', '--upgrade', package]) instead. pip.main just takes arguments exactly like the command line version.
4 Comments
spruceb
I was assuming
package was a variable containing the name of whatever package OP wants to upgrade.dcarroll9999
Yes,
package was a variable that had a string inside it. Here is the class; def pipInstall(package): pip.main(['install', '--upgrade', package])spruceb
Did that do it for you then? It works on my machine.
subprocessmodule