When using Python for data analysis or processing, it is often necessary to use a package, which must be installed before you can use it. The Anaconda installation package contains a number of commonly used packages that meet most of the requirements, such as numpy, Pandas, matplotlib, and so on, so you do not need to install them separately. But some of the less common, or niche, package needs to be installed manually.
There are two ways to determine if a package is installed:
1) Import in the Spyder or Jupyter, if prompted to import the error, it is not installed on behalf of the package;
2) When Anaconda is installed, search in Anaconda Navigator and see if the package is installed.
The installation methods are mainly divided into the following types:
(1) Under Anaconda Environment:
Locate the package in Anaconda Navigator, and then select and install it.
Once the installation is successful and viewed in Anaconda Navigator, the check box in front of the package is checked. Represents a successful installation.
However, not all of the package can be found in Anaconda Navigator. For example, for Chinese participle of stuttering participle.
(2) Under non-Anaconda environment:
Method 1: Install with setup.py
1) in the official website download package corresponding compressed file, Zip\tar\gz and other formats, and unzip.
2) Use the command line to switch to the directory where setup.py is located in the extracted file
3) Use the Python setup.py install command to execute the installation file for installation
Method 2: Install using the Easy_install tool
If you have a Ez_setup package installed, you can use Method 1 to install the package.
On the command line, use the command directly easy_install the URL of the package_name or the resource or the. egg file
easy_install package_nameeasy_install package_download_urleasy_install package.egg
Method 3: Install using the PIP tool
If you have a PIP package installed, PIP will be installed automatically in python2.7 or python3.5 or Anaconda installation. If manual installation is required, either Method 1 or Method 2 can be used.
On the command line, use the command pip install package_name directly
pip install package_name
You can also use the PIP command to uninstall a package
pip uninstall package_name
For the downloaded WHL file, you need to install it using the PIP tool: first switch the cmd current directory to the path where the WHL file is located, and then use the PIP install PACKAGE.WHL command to
pip install package.whl
Method 4: Install directly
Some packages are packaged as an. exe or. Mis, and can be downloaded directly by double-clicking the installation on Windows
Rediscover Python (2): How to install a new package (Windows)