Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to upgrade the Python library in Ubuntu18.04

2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)05/31 Report--

Today, I would like to share with you how to upgrade the Python library in Ubuntu18.04. The content is detailed and the logic is clear. I believe most people still know too much about this knowledge, so share this article for your reference. I hope you can get something after reading this article.

What is Python mainly used for?

Python is mainly used for: 1. Web development; 2. Data science research; 3.Web crawler; 4. Embedded application development; 5. Game development; 6. Desktop application development.

Upgrade the pip version

Pip (pip 9.0.1) included with Ubuntu is based on Python2.7 by default

We need to reinstall pip based on Python3:

Sudo apt-getinstalpyth3-pip= upgrade pip3 version:

Python3-mpipin install-upgrade pip looks at the PIP version of Python3 if the following error is reported:

Import error: unable to import primary name

Solution: edit the usr/bin/pip3 file

Before modification:

Frompipimportmain

If__name__=='__main__':

Modified sys.exit (main ()):

Frompipimport__main__

If__name__=='__main__':

Sys.exit (_ _ main__. _ main () validation fix has taken effect successfully: pip3-V

Terminal printing:

Pip19.3.1from/home/work/ . Local/lib/python 3.6/site-packages/pip (python 3.6)

Next, upgrade all Python packages with one click

Write a Python script to execute. Here is the code:

Importpkg_resources

Fromsubprocessimportcall

For package in [dist. Project _ name for istinpkg _ resources. Working _ set]:

Call ('pip3install-upgrade''). Join (packages)'- user', shell=true) because the pip corresponding to my Python3 is pip3, the script is called here ('pip3install-upgrade''. Join (packages)'- user', shell=true)

Next, take a look at Python's version history package and those:

Pip3 list-outdated terminal printing:

PackageVersionLatestType

-

Distro-info 0. 0. 00. 10 dist

Py cairo 1. 16. 21. 18. 1 dist

Pycups 1. 9. 731. 9. 74 dist

Then use Pygobject3.26.13.34.0sdist for these packages that have not yet been upgraded

These are all the contents of the article "how to upgrade the Python Library in Ubuntu18.04". Thank you for reading! I believe you will gain a lot after reading this article. The editor will update different knowledge for you every day. If you want to learn more knowledge, please pay attention to the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report