One trick teaches you to import all python third-party libraries (such as OpenCV library, matplotlib library, imutils library, numpy library ...)

I used python3.5 in the past. When installing the matplotlib library today, I suggested that the python version must be 3.6 or above. In desperation, I directly reinstalled python3.8.2 and some commonly used python third-party libraries. After reading all kinds of information, I want to summarize the simplest general formula for installation that I know about in this regard, and give it to my friends who are confused in this respect.

table of Contents

Know your computer and python version

If downloading a WHL file

If you download a compressed file

Exception


Know your computer and python version

First of all, we must have some understanding of our computer, the most important is the type of computer system and the version of python you have installed

For my computer, the system type is a 64-bit operating system (× 64), and the python version is 3.8.2

The installation of python will not go into details, just go to the official website to download and install it directly, the official website link: https://www.python.org/

In terms of installing python third-party libraries, we usually choose to download whl files or compressed file packages from the following two websites
https://www.lfd.uci.edu/~gohlke/pythonlibs/
https: // pypi. org / project /

First, find the corresponding version to download. Here is a brief introduction to the OpenCV library as an example

. Opencv_python is the name of the third-party library.
           After the library name, 4.2.0 and 4.1.2 are
           35,36,37, etc. behind the library version number cp. 38 is the python version, for
example python3.8.2 is cp38, the
           last win is windows, 32 or 64 is the version number of the computer operating system

If downloading a WHL file

Step 1: Place the whl file under the path of the Scripts folder in the python installation package (for example, my path is E: \ software \ python3.8.2 \ Scripts)

Step 2: Windows + R key, enter cmd to open the command window Enter the pip install whl file path
               as mine is to enter pip install E: \ software \ python3.8.2 \ Scripts \ opencv_python-4.2.0-cp38-cp38-win_amd64.whl
  Note: The whl file path can be right -clicked in the property security bar View

this point, whl file is installed, it is not very simple, O (∩_∩) O haha ~
check whether installed by typing in cmd after entering python import + library name is installed , for example:

if you show up If the same as the above picture, then congratulations, the installation is successful!

If you download a compressed file

This is another case, you download a file compression is
the first step, first of all, to extract the "filename", then its fall python site-packages installer file in the Lib folder (for example, I The file is stored in the path E: \ software \ python3.8.2 \ Lib \ site-packages) The

second step is the same as the whl file, Windows + R key, enter cmd to open the command window, enter pip install The decompressed file The folder path
             as mine is to enter pip install E: \ software \ python3.8.2 \ Lib \ site-packages \ imutils-0.5.3.

At this point, the library in the form of a compressed file is installed, is it also very simple? , O (∩_∩) O haha ​​~

Exception

During our installation process, most of the third-party libraries can be installed in the above two forms,
but some libraries are very unfriendly.
Here are some, such as the matplotlib third-party library mentioned at the beginning of this article, he has his own installation the way

matplotlib third-party library
Step:
enter python -m pip install -i http://pypi.tuna.tsinghua.edu.cn/simple --trusted-host pypi.tuna.tsinghua.edu.cn matplotlib directly in the cmd command window Just

At the end of this article, we provide you with a shortcut key to view the installed python third-party library in PyCharm: Ctrl + Alt + S

The above picture is the import situation of the python third-party library after I just downloaded the python 3.8.2 version.

 


 

 

If you find any problems during the implementation process, you can contact at any time, or you can leave your questions in the comment area below.
I will also update if I find new and easier methods.

Welcome everyone to exchange comments and study together

Hope this article can help you solve the problems you have encountered in this regard

Thanks for
readingEND

Published 30 original articles · 200 praises · 20,000+ views

Guess you like

Origin blog.csdn.net/IT_charge/article/details/105586808