Home  >  Article  >  Backend Development  >  How to install python library

How to install python library

藏色散人
藏色散人Original
2019-10-26 10:36:266382browse

How to install python library

How to install the python library?

1. Preparation work

(Only do the preparation work once, it will be very convenient in the future)

Recommendation: "python tutorial"

1. Install pip

(1) Download pip to D:\download

pip download address: https://pypi.python.org/pypi/pip#downloads

How to install python library

(2) After downloading, extract it to the current directory;

(3) "win R" to enter cmd; enter the following code in sequence:

C:\Users\Administrator>cd D:\download\pip-9.0.1
C:\Users\Administrator>d: 
D:\download\pip-9.0.1>python setup.py install

(4) Configure environment variables:

Add the pip installation path in PATH: Script folder under the python installation path

How to install python library

(5 ) Complete

Re-"win R" to enter cmd; run the following code directly:

Run: pip -V or pip --version, display the version information of pip

How to install python library

2. Install wheel

(for offline installation of downloaded whl files)

"win R" to enter cmd; directly run the following code:

pip install wheel

2. Install third-party libraries

1. Online installation

Run directly in the cmd window: pip install package name, such as pip install requests

Note: When installing in this way, the third-party library will be automatically downloaded and will not be deleted after the installation is completed. If you need to delete it, please go to its default download path and delete it manually;

default for win7 Path://AppData may be a hidden folder

c:\User\(your username)\AppData\Local\pip\cache\

Default path for linux:

~/.cache/pip

In fact, there is no need to delete the cache. You can disable the cache by adding --no-cache-dir.

2. Offline installation

(1) Download

Download the .whl file of the required library at http://www.lfd.uci.edu/~gohlke/pythonlibs/. Note that the cp** in the file name should be the same as The installed version matches. If you install Python2.7, you should download the corresponding cp27 .whl file

(2) Install

and run: pip install **.whl, provided that wheel has been installed.

3. Unzip and install

Rename the .whl suffix to zip, unzip it, and put the unzipped folder into Python/Lib/site-packages

The above is the detailed content of How to install python library. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn