jason jason - 3 months ago 10
Python Question

upgrading python module within code

My question relates to this question: Installing python module within code, but involves upgrading the module.

I've tried

packages=['apscheduler','beautifulsoup4','gdata']

def upgrade(packages):
for package in packages:
pip.main(['install --upgrade', package])


and

def upgrade(packages):
for package in packages:
pip.main(['install', package + ' --upgrade'])

Answer

Try pip.main(['install', '--upgrade', package]).

"--upgrade" is a separate command-line argument, so you need to pass it separately to main.

Comments