Problems and solutions for installing matplotlib modules in Python

Source: Internet
Author: User
Tags win32 install matplotlib nltk in python

The first time to write technical articles, no advanced content, just as a Python beginner, in the installation of Third-party module Matplotlib encountered a lot of problems, want to put these problems and its solution to record, on the one hand, when they forget the time to find out to see, On the other hand also hope to give a reference to the future beginners, hoping to help them to take less detours. Contact Matplotlib is due to the recent reading of the book "Natural language Processing in Python", after installing NLTK and Python, to use the Dispersion_plot () function to draw a discrete diagram, the result is to install the Matplotlib module, I thought it was a simple thing to know the installation of things are quite a lot of, the hand-bought a morning finally finished, now the problems encountered and solutions summarized below.



Correct process for installation:
1. First install Python, I use the 32-bit python3.4.1 (download address can go: http://www.nltk.org, of course, can go to the official website, but NLTK official on the web to give the corresponding version of the NLTK required Python version)

2. Install NLTK (version Nltk-3.0.1.win32), a natural language tool under Python that integrates many of the functions needed to handle natural languages. (Download address: IBID.)

3. Install NumPy (version numpy-1.8.1-win32-superpack-python3.4) (Download address: http://www.scipy.org/scipylib/download.html)

4. Install scipy (version scipy-0.15.1-win32-superpack-python3.4) (Download address: IBID.)

5. Install Matplotlib (version matplotlib-1.4.1.win32-py3.4) (Download address: http://matplotlib.org/)

6. Install Dateutil (version Python_dateutil-2.3-py2.py3-none-any) (Download address: http://www.lfd.uci.edu/~gohlke/pythonlibs/)

7. Install pyparsing (version Pyparsing-2.0.3-py3-none-any) (Download address: IBID.)


Among them, some of the modules in NumPy and scipy are required to import matplotlib and should be installed.


The problems encountered:

1. Initially, after loading nltk,numpy and scipy and matplotlib, I imported the Matplotlib module directly into the Python interactive command line, which prompted the missing module six, as shown in the following illustration:


This module is really just loaded in the SCIPY package, find its own PYTHON installation directory, and then%python_root%\lib\site-packages\scipy\lib the SIX.PY,SIX.PYC, Six.pyo three files in the%python_root%\lib\site-packages directory to solve this problem, here%python_root% refers to your computer on the Python installation of the root directory, such as I was the python installed in the C-packing directory , so the%python_root% on my computer represents C:\python27, which is different depending on the directory where you install PYTHON yourself.



2. After resolving the above problem, again in the Python interactive command line, import the Matplotlib module, the result still prompts error, the following figure:


According to the prompts to know, matplotlib need dateutil, so we need to install the Dateutil in the 6th step, in the link I gave, Now you can only go down to the. WHL format of the installation files, this is Python's own package files need to use Python package management software to install, Python comes with the package management software commonly has setuptools and pip two kinds, I used here is the PIP to install. It's best to add your own environment variables before you use them, so that when you use them, the full path to the PIP program is more cumbersome. Add the following address to the last face of the system variable path:%python_root%\scripts. Among them,%python_root% is still the root directory of PYTHON. The installation process is as follows: Will download the good Dateutil installation package, put it in a directory, such as I put it in the D-packing directory, and then open the Windows Command Line window, please note that Windows Command Line window, and then enter the D-packing directory, and then enter the following command, as shown in the lower part of the following figure:




3. After installing the Dateutil, the import matplotlib still prompts the error, the hint lacks pyparsing module, according to the second step way, downloads installs the file, after the installation completes, then may import the Matplotlib module correctly, installs the command as shown in the upper part of the picture above, Don't repeat it here. Successfully imported after proper installation, as shown in the following illustration:




Summary: The installation process is actually more troublesome, mainly to import the module too much, fortunately the Python interpreter will give detailed instructions, we can follow it is only step-by-step to complete the installation of the module. The last thing to note is that because there are a lot more packages to install, Python is divided into two large branches 2.x and 3.x, so I hope you download each package, the main find a matching package, such as I installed is 3.4 of Python so the download package should also be adapted to 3.4 of the package, these packages are generally noted in the name of which version of Python, such as Numpy-1 8.1-win32-superpack-python3.4, this numpy bag is suitable for 3.4. This is a detail, please note that if you install the python3.x and installed the package is suitable for python2.x may appear mismatch.


This article wrote that this is all over, if everyone in the installation of these bags (nltk,numpy,scipy,matplotlib) encountered a problem, you can give me a message, I will respond promptly.

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.