Python Installation matplotlib,six,dateutil,pyparsing Complete process

Source: Internet
Author: User
Tags install matplotlib

Matplotib is a Python drawing library, there are a variety of drawing methods, you can display images with MATPLOTIB, enlarge the image, save the image and so on, for OPENCV processing the image with great help. However, installing MATPLOTIB will run into a series of problems because Matplotlib needs to rely on a number of other scientifically computed third-party libraries, requiring one installation.

The following is a complete solution based on the Win7 32/64-bit system:

Python's third-party module typically comes with setup.py files, and in a Windows environment, we only need to use the cmd command:

CD c:\python\.

Python setup.py Install

Two commands to complete the installation of the third-party module.

The first CD command will currently switch to the directory of the third-party module to be installed (this assumes that the directory after the third-party module decompression is c:\python278\. If the other drive letter, such as G-disk, executes the first D:, the second command executes the installation.

The error message "Importerror:no module named Setuptools" may appear during installation, which is a common error message that novice users encounter. Don't worry, this is because Python does not have the Setuptools module installed by default in the Windows environment, which is also a third-party module.

1, install Setuptools

download directly from the website:http://pypi.python.org/pypi/setuptools

If it is a Windows environment, download Setuptools-18.2.zip, unzip, enter the directory, double-click ez_setup.py, you can complete the installation.

Once Setuptools is installed, it is easy to install a variety of third-party modules by running Python setup.py install.

2, install Matplotlib

Download directly from the website: http://matplotlib.sourceforge.net/

After I found the corresponding version of the. exe file, I used matplotlib-1.4.3-py2.7, direct import matplotlib,

The error is as follows:

And then we're installing six.

3, install six

Official website Download: http://www.pythonhosted.org/six/

I downloaded the six-1.9.0 source compression package six-1.9.0.tar.gz, after decompression, into the Extract directory, command line execution Python setup.py install can be completed.

Import Matplotlib again later or missing library: Dateutil

4, install Dateutil

Official website Download: https://pypi.python.org/pypi/python-dateutil/1.4.1

I downloaded the python_dateutil-1.4.1-py2.7, source installation also to the decompression directory, execute Python setup.py install can also be installed successfully,

Continue execution: import matplotlib; still error: Missing pyparsing library

5, install pyparsing

Official website Download: http://sourceforge.net/projects/pyparsing/files/pyparsing/pyparsing-2.0.3/
Download Pyparsing-2.0.3.win32-py2.6.exe, double-click Run, install complete = =
Still import matplotlib, still missing: NumPy:

6, install NumPy

Official website Download: http://www.numpy.org/

Download Numpy-1.9.1-win32-superpack-python2.7.exe, install NumPy success:

Execute import matplotlib ok! It's fun to use OpenCV on Python!

Test code:

Import CV2 Import numpy as Npfrom matplotlib import pyplot as Pltimg = Cv2.imread ("finger.jpg") cv2.imwrite (' 1gray.png ', img ) Cv2.namedwindow ("image") cv2.imshow ("Image", img) plt.imshow (img, cmap = ' gray ', interpolation = ' bicubic ') plt.xticks ( []), Plt.yticks ([]) # To hide ticks values on X and Y axisplt.show () k = Cv2.waitkey (0) &0xffif k = = +: # wait for ESC K EY to exit    cv2.destroyallwindows () elif k = = Ord (' s '): # Wait for ' s ' key to save and exit    Cv2.imwrite (' MESSIGRAY.P Ng ', img)    cv2.destroyallwindows ()

  

Implementation results:

Python Installation matplotlib,six,dateutil,pyparsing Complete process

Related Article

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.