The most detailed method of python installation library (take the installation of pygame library as an example)

Article directory

foreword

🚀🚀  Python installation library method Daquan (take the installation of pygame library as an example)

🚀Method 1. Install directly inside pycharm [the easiest method (directly above)]

🚀Method 2, (install the library in the terminal)

        Install :

        ✨1. Use pip install + (name of library) to install directly

        ✨2. Use domestic mirror installation (adding the mirror address speed is fast💪💪)

        ​​​🎉🎉 Method 2 What should I do if the following error is reported

        🎉🎉Summary Method 1 and Method 2

 Epilogue


Foreword:

👉For beginners, the installation of the library is the first challenge encountered. I have also entered a lot of pits, so I came up with the steps to install the library in the first phase. Due to the limitation of the blogger's level, the blog will inevitably have errors and inaccuracies. I also very much hope that you can point it out in the comment area. Let's work together.

🚀🚀  Python installation library method Daquan (take the installation of pygame library as an example)

🚀Method 1. Install directly inside pycharm [the easiest method (directly above)]

  • If the first method cannot be installed, use the second method

watermark,type_d3F5LXplbmhlaQ,shadow_50,text_Q1NETiBA5Zyo5LiL5ZGo5ZGob3Zv,size_20,color_FFFFFF,t_70,g_se,x_16

watermark,type_d3F5LXplbmhlaQ,shadow_50,text_Q1NETiBA5Zyo5LiL5ZGo5ZGob3Zv,size_20,color_FFFFFF,t_70,g_se,x_16

watermark,type_d3F5LXplbmhlaQ,shadow_50,text_Q1NETiBA5Zyo5LiL5ZGo5ZGob3Zv,size_20,color_FFFFFF,t_70,g_se,x_16

If it shows package pygame (library name) install successfully   to the end of the first method, congratulations on your successful installation

If an error is reported, use the second method

🚀 Method 2 (install the library in the terminal)

win+r : open run input cmd

watermark,type_d3F5LXplbmhlaQ,shadow_50,text_Q1NETiBA5Zyo5LiL5ZGo5ZGob3Zv,size_20,color_FFFFFF,t_70,g_se,x_16

Then cd to the scripts under your python interpreter (for example, my path is D:\Program Files (x86)\python\Scripts)

watermark,type_d3F5LXplbmhlaQ,shadow_50,text_Q1NETiBA5Zyo5LiL5ZGo5ZGob3Zv,size_20,color_FFFFFF,t_70,g_se,x_16

watermark,type_d3F5LXplbmhlaQ,shadow_50,text_Q1NETiBA5Zyo5LiL5ZGo5ZGob3Zv,size_17,color_FFFFFF,t_70,g_se,x_16

After finding this path, the installation will start below

 

watermark,type_d3F5LXplbmhlaQ,shadow_50,text_Q1NETiBA5Zyo5LiL5ZGo5ZGob3Zv,size_20,color_FFFFFF,t_70,g_se,x_16

 cd into the scripts and enter any of the following three to install the library

Installation
1. Use pip install + (name of library) to install directly

pip install (name of the library) For example, if I want to install the Pygame library, enter ( pip install pygame ) until it shows Successfully

However, the installation speed of this method is a bit slow, and what should I do if the installation fails to report an error directly in the end? ? Don't worry, we will use the domestic mirror source at this time (replacing the pip installation source with a domestic mirror can greatly improve the download speed and the installation success rate.)

The domestic mirror addresses are as follows

Tsinghua University: https://pypi.tuna.tsinghua.edu.cn/simple

Aliyun: http://mirrors.aliyun.com/pypi/simple/

University of Science and Technology of China https://pypi.mirrors.ustc.edu.cn/simple/

Douban: http://pypi.douban.com/simple/

2. Use domestic mirror installation (adding the mirror address speed is fast💪💪 )

✨Installation method (pip install + library name + -i + mirror address)

You can add parameters when using pip (that is, the installed mirror address)

Take Douban source as an example to install pygame. I want to input: pip install pygame -i http://pypi.douban.com/simple

If you enter the mirror address and still cannot download, it shows that the address cannot be trusted (Try to run this command from the system terminal. Make sure that you use the correct version of 'pip' installed for your Python interpreter located at), then what should I do? What to do? Ah~~ don't worry 😎😎😎

Then use the enhanced download : pip install (library name) -i https://pypi.tuna.tsinghua.edu.cn/simple --trusted-host pypi.tuna.tsinghua.edu.cn scikit-learn

 The newly added paragraph is to make it trust this address

Direct demo (pip install  pygame -i https://pypi.tuna.tsinghua.edu.cn/simple --trusted-host pypi.tuna.tsinghua.edu.cn scikit-learn)

 At this point, the basic library can be installed. Here are some other commands that will be used:


pip install -U ... update

pip unistall ... uninstall

pip download ... download without installing

pip show ... show library details

pip list list installed libraries

python -m pip install --upgrade pip -i https://pypi.tuna.tsinghua.edu.cn/simple/

Check your pip version. If the pip version is too low (now the highest is 20.0.2), please update pip~~~

​​​🎉​​​​​​​​🎉 Method 2 What should I do if the following error is reported

                                                      

 This error means that your pip has not been updated. You just need to execute the following two commands in sequence as he said, and then you can use the second method to install:

1. The corresponding version of pip will be installed

python -m ensurepip

after:

2. Just update the pip installed above to the latest version, and then you can use method two to install~~

python -m pip install --upgrade pip

🎉​​​​​​​🎉Summary method 1 and method 2

Do I have to install it in cmd (command prompt installation) or in Pycharm? ? ? ? Is there any difference?

cmd install:

Advantages: One-time installation, easy to use. Libraries installed in cmd, when using IDEs such as Pycharm to load the interpreter, all libraries will be loaded, which is very convenient. There is no need to load the required library every time it is used;

Disadvantages: Because all libraries will be loaded at one time, this will cause a waste of resources. For example, if a project needs to use a library related to pygame, other than the library related to pygame, other libraries will not be used, which will slow down the editor.

Pycharm installation:

Advantages: Each project loads the required libraries separately, without wasting resources;

Disadvantage: Every new project needs to be reloaded, which is a bit cumbersome.

In short, whether it is installed in cmd or installed in Pycharm, both have their own advantages and disadvantages, but the ultimate goal is to install the libraries we need. Which method can be used? Whichever method works best, we will use it~~ 😎😎😎

 Epilogue

The above is the installation method of the library I shared. If there is any mistake, please correct me~~~ 🔥🔥🔥

watermark,type_d3F5LXplbmhlaQ,shadow_50,text_Q1NETiBA5Zyo5LiL5ZGo5ZGob3Zv,size_17,color_FFFFFF,t_70,g_se,x_16

Tags: The most detailed method of python installation library (take the installation of pygame library as an example)

Learn python basics from scratch in 100 days python

Related: The most detailed method of python installation library (take the installation of pygame library as an example)