Bluemix: How to upgrade pip?

2019-05-30 17:26发布

问题:

I got this warning when I run my python app on bluemix:

You are using pip version 7.1.0, however version 8.1.0 is available.

How do I run shell commands like "pip install --upgrade pip" in my cf app?

Adding "Shell script" step on Build or Deploy stage gave me pip not found error.

Thanks!

回答1:

You can't run arbitrary commands while the application is being staged, i.e. when pip would be used.

If you can't ignore the warning, you could try the Heroku Python buildpack which is updated to use 8.1.0 by using the -b option when pushing your app, but I can't comment on how they are otherwise different.

cf push appname -b https://github.com/heroku/heroku-buildpack-python.git

Update: Another way is by creating your own buildpack and update manifest.yml to use this buildpack (preferably by building it up from similar buildpack if it exists). This article shows how to create a buildpack.



回答2:

PIP requires superuser permission and you can not upgrade pip with !pip install --upgrade pip command. It needs to be done at the system level and it will be done whenever the development team pushes next release of code.