1. What is pip pip is a Python package management tool that provides the functions of searching, downloading, installing, and uninstalling Python packages. 2. Upgrade pip version 1. The default pip (pip 9.0.1) that comes with Ubuntu is based on Python 2.7 2. We need to reinstall pip based on Python3: 3. Upgrade pip3 version: 4. Check the pip version of Python3. If the following error is reported: ImportError: cannot import name main Solution: Edit the usr/bin/pip3 file Before modification: from pip import main if __name__ == '__main__': sys.exit(main()) After modification: from pip import __main__ if __name__ == '__main__': sys.exit(__main__._main()) Verify that the fix has taken effect successfully: pip3 -V The terminal prints: pip 19.3.1 from /home/wenbin/.local/lib/python3.6/site-packages/pip (python 3.6) 5. Upgrade all Python packages with one click Just write a Python script to execute it. Here is the code: import pkg_resources from subprocess import call for packages in [dist.project_name for dist in pkg_resources.working_set]: call("pip3 install --upgrade " + ''.join(packages) + ' --user', shell=True) Because the pip corresponding to my Python3 is pip3, the pip in the script call("pip3 install --upgrade " + ''.join(packages) + ' --user', shell=True) should be written as pip3 Next, let's check what other packages there are in the historical versions of Python: The terminal prints: Package Version Latest Type ----------- ------- ------ ----- distro-info 0.0.0 0.10 sdist pycairo 1.16.2 1.18.1 sdist pycups 1.9.73 1.9.74 sdist pygobject 3.26.1 3.34.0 sdist Then use these non-upgraded packages You can run the command to upgrade them one by one. I don’t use those four packages often, so I’m too lazy to upgrade them. . . (PS: I just installed Ubuntu 18.04, so it’s not convenient to take screenshots. Let’s just watch it for now-.-) Knowledge point extension: Ubuntu 18.04 installs Python package Recently, I have been running two models at the same time, and the cloud server can't handle it. I got a company windows host, changed it to ubuntu18.04 and gave it to me to use mbp remote ssh. Cool~ 1. Configure ssh-server 2. Install Python, etc. Unbuntu18.04 comes with python3.6.8 1. Install pip3 and execute 2. Install vim and execute 2. Configure the image first and then install each python package Torch actually shows that it takes 20 hours to download, so I still use Tsinghua pypi mirror 8~ Note that an error may occur after upgrading pip10
Just add --user after install: Summarize The above is the method of upgrading all third-party Python packages and installing Python packages in Ubuntu 18.04 with one click. I hope it will be helpful to everyone. If you have any questions, please leave me a message and I will reply to you in time. I would also like to thank everyone for their support of the 123WORDPRESS.COM website! You may also be interested in:
|
<<: MySQL 8.0.15 installation and configuration tutorial under Win10
>>: Detailed explanation of JavaScript WebAPI, DOM, events and operation element examples
Preface: I recently started to study the construc...
Table of contents First we need to build the page...
The blogger said : I have been writing a series o...
Nginx: PV, UV, independent IP Everyone who makes ...
Correspondence between flutter and css in shadow ...
Table of contents Preface 1. Use for...of to iter...
Table of contents mapState mapGetters mapMutation...
In Windows operating system, the program to query...
This article mainly discusses the differences bet...
1 CSS style without semicolon ";" 2 Tags...
This article example shares the specific code of ...
Table of contents 1. Understanding Queues 2. Enca...
The hardware requirements for deploying Hyper-V a...
1. Create a database 2. Create a table 1. Create ...
1. getBoundingClientRect() Analysis The getBoundi...