Named PIL solution for Python27 No module __python

Source: Internet
Author: User
Tags pack

The Pil:python Imaging Library is already the de facto standard library of image processing for the Python platform.

However, when we do image processing, we will report No module named PIL exception. A library with no image processing. Because Python2.7 didn't bring the library, we wanted to load and manipulate the library ourselves. However, there is a wide variety of online information, there is no specific explanation. In order to save time and not be misled, I will write out the complete solution.

1. Install Easy_install

Why are you pretending to be easy_install?
Normally, to install a third party expansion pack for Python, we first download the package, unzip it to a directory, and then the command line or terminal opens the directory, then executes the Python setup.py install to install it. Very cumbersome. If we directly command the line to execute Easy_install twisted it is convenient to pack the twisted. So Easy_install is easier for us to install a Third-party expansion pack.

Easy_install Download Path: Https://github.com/ActiveState/ez_setup

Unzip the compression pack, open the command line, and execute the python ez_setup.py

2. Install Pip

Installing the Python package, which is really the most convenient, simple and fast, because it is directly from the PyPI download files, to ensure that the file security and reliability, and rich in resources. The PIP is a tool for installing and managing a Python package.

Download path: HTTPS://GITHUB.COM/PYPA/PIP

Unzip the compression pack, open the command line, and execute the python setup.py install

Normally, it should be unpacked in your Python installation path, and I'm just trying to make it easier to demo. After the PIP is installed, there is a scripts folder under our Python installation path, we need to configure the environment variables for the PIP, and the configuration of the environment variables is too simple for me to demonstrate.

3. The next step is to install the PIL.

Download path: http://www.lfd.uci.edu/~gohlke/pythonlibs


Before installing PIL, we need to install the wheel package. Essentially wheel is a compressed format package. Install with the Python module.

Perform pip install wheel at the command line because I have already installed it and can't show it well.



Next, we can install the good PIL. Perform pip install PILLOW-4.1.0-CP27-CP27M-WIN_AMD64.WHL

Because I have been installed, so it is not very good to display. When we install PIL successfully, we will be prompted to successfully.

Let me tell you how to install the WHL file:

① If you add the D:\Python27\Scripts directory to path, you can directly execute the following statement by opening a CMD window in the directory where the WHL file is located, with the administrator.

Pip Install PILLOW-4.1.0-CP27-CP27M-WIN_AMD64.WHL

② Otherwise, you need to open cmd in the D:\Python27\Scripts directory with admin, run PIP command, filename should write full path.

Pip Install C:\USERS\XXX\DOWNLOADS\PILLOW-4.1.0-CP27-CP27M-WIN_AMD64.WHL

4. Installation Complete

At this point, our PIL module has been successfully installed. We will be able to use it in python2.7.

Introducing PIL, the code is from PIL import Image.

5. End

Although the difference between python2.7 and python3.0 is small, it is inevitable that there is a compatibility problem. For example, more than 3.0 have their own pip,2.7 is not. So we're going to do the operation. But because of habitual, accustomed to use python2.7, so I need to download files and operations. Hopefully this article will help you still use python2.7.

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.