How to install third-party libraries on the official website of non-PyPI using pip in Python

Source: Internet
Author: User
This article mainly introduces how to install third-party libraries of non-PyPI official website by pip in Python. The latest version of pip (version 1.5 or later) is out of security considerations, pip does not allow installation of non-PyPI URLs. This article provides two solutions. you can refer to the following three methods to install a non-built-in python module in python:

1. easy_install
2. pip
3.download the compressed package (.zip,. tar, .tar.gz), decompress the package, enter the decompressed directory, and run the python setup. py install command

This article focuses on a possible situation during pip installation and solutions:

If I want to install the pylint module, this module is not a python built-in module, but cannot be imported with import. Additional installation is required.

The code is as follows:


>>> Import pylint
Traceback (most recent call last ):
File" ", Line 1, in
ImportError: No module named pylint

[Symptom]

Execute pip install Command, the error is as follows:

The code is as follows:


D: \> pip install pylint -- allow-external pylint
Downloading/unpacking pylint
Requirement already satisfied (use -- upgrade to upgrade): six in c: \ python27 \ lib \ site-packages \ six-1
. 8.0-py2.7.egg (from pylint)
Downloading/unpacking astroid> = 1.3.6 (from pylint)
Real name of requirement astroid is astroid
Cocould not find any downloads that satisfy the requirement astroid> = 1.3.6 (from pylint)
Some insecure and unverifiable files were ignored (use -- allow-unverified astroid to allow ).
Cleaning up...
No distributions at all found for astroid> = 1.3.6 (from pylint)
Storing debug log for failure in C: \ Users \ aaa \ pip. log

[Analysis]

Install a new module in Perl. Generally, you can use the PPM graphical tool or CPAN to install the module. for example, cpan> install Test: Class is very convenient, this is mainly because of the pip version: the latest version of pip (version 1.5 or later ).
Note: pip does not allow installation of non-PyPI URLs, because the installation file is actually from pylint.org, leading to the above error!

NOTE:

1. you can view the changed information in the official changelog.
2. you can use pip -- version to view pip version information.

The code is as follows:


C: \> pip -- version
Pip 1.5.6 from C: \ Python27 \ lib \ site-packages (python 2.7)

[Method]

For the above situation, since this problem is caused by the pip version, you can use a version earlier than pip.
Method 1: use pip 1.4 and then run pip install pylint to install
Method 2: when executing the command, add -- allow-all-external, -- allow-unverified and the dependent package version (astroid = 1.3.6)

The code is as follows:


Pip install pylint -- allow-all-external pylint astroid = 1.3.6 -- allow-unverified pylint


NOTE:
1. -- allow-all-external # allow all external address tags. Only pip can download the external address module.
2. -- allow-unverified # pip cannot verify the validity of the external module. Therefore, this label must be added at the same time.
3. astroid = 1.3.6 # The dependent package must be added and the version number must be assigned to it. pip can be downloaded from the list.

Method 3: Add requirements.txt in the current directory. the content is as follows:

The code is as follows:


# Requirements.txt
-- Allow-all-external pylint
-- Allow-unverified pylint
Pylint
-- Allow-all-external astroid = 1.3.6

Run pip install-r requirements.txt.
[Conclusion]
1. pip is not well-designed and inconvenient to use. it is far inferior to PPM in Perl and is expected to have such a tool in Python.
2. if this error occurs, the module cannot be installed: Download the compressed package and install it. >>> Download package address <
3. run the pip-h command to view pip-related help information.

The code is as follows:


Usage:
Pip[Options]

Commands:
Install Install packages.
Uninstall Uninstall packages.
Freeze Output installed packages in requirements format.
List List installed packages.
Show Show information about installed packages.
Search Search PyPI for packages.
Wheel Build wheels from your requirements.
Zip DEPRECATED. Zip inpidual packages.
Unzip DEPRECATED. Unzip inpidual packages.
Bundle DEPRECATED. Create pybundles.
Help Show help for commands.

General Options:
-H, -- help Show help.
-V, -- verbose Give more output. Option is additive, and can be used up to 3 times.
-V, -- version Show version and exit.
-Q, -- quiet Give less output.
-- Log-file Path to a verbose non-appending log, that only logs failures. This log is active by default at pip. log.
-- Log Path to a verbose appending log. This log is inactive by default.
-- Proxy Specify a proxy in the form [user: passwd @] proxy. server: port.
-- Timeout Set the socket timeout (default 15 seconds ).
-- Exists-action Default action when a path already exists: (s) witch, (I) gnore, (w) ipe, (B) ackup.
-- Cert Path to alternate CA bundle.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.