How do I update a Python package?

后端 未结 12 2256
半阙折子戏
半阙折子戏 2020-11-29 15:47

I\'m running Ubuntu 9:10 and a package called M2Crypto is installed (version is 0.19.1). I need to download, build and install the latest version of the M2Crypto package (0.

12条回答
  •  醉话见心
    2020-11-29 16:00

    To automatically upgrade all the outdated packages (that were installed using pip), just run the script bellow,

    pip install $(pip list --outdated | awk '{ print $1 }') --upgrade
    

    Here, pip list --outdated will list all the out dated packages and then we pipe it to awk, so it will print only the names. Then, the $(...) will make it a variable and then, everything is done auto matically. Make sure you have the permissions. (Just put sudo before pip if you're confused) I would write a script named, pip-upgrade The code is bellow,

    #!/bin/bash
    sudo pip install $(pip list --outdated | awk '{ print $1 }') --upgrade
    

    Then use the following lines of script to prepare it:

    sudo chmod +x pip-upgrade
    sudo cp pip-upgrade /usr/bin/
    

    Then, just hit pip-upgrade and voila!

提交回复
热议问题