How to install the library in python?
The easiest way to install third-party libraries in python
Recommended: "Python Tutorial"
1. Preparation work
(Only do the preparation work once, it will be very convenient in the future)
1. Install pip
(1) Download pip to D: \download
pip download address: https://pypi.python.org/pypi/pip#downloads
## (2) After downloading, extract to the current Directory; (3) "win R" to enter cmd; enter the following codes 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
##2. Install wheel
(for offline installation Downloaded whl file)
"Win R" enter cmd; directly run the following code:
pip install wheel
1 . Online installation
Run directly in the cmd window: pip install package name, such as pip install requests
Note: The third-party library will be automatically downloaded during installation in this way, and will not be installed after the installation is completed. Delete. If you need to delete, please go to its default download path and delete it manually;
The default path of win7: //AppData may be a hidden folder
c:\User\(your user name)\AppData\Local\pip\cache\
Default path for linux:
~/.cache/pip
In fact, there is no need to delete the cache, add - -no-cache-dir can disable caching
2. Offline installation
(1)Download
At http://www.lfd.uci.edu/ ~gohlke/pythonlibs/ Download the .whl files for the required libraries. Note that the cp** in the file name should match the installed version. If you are installing Python2.7, you should download the corresponding cp27 .whl file
(2) Installation
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 libraries in python. For more information, please follow other related articles on the PHP Chinese website!