Installation and configuration of Numpy, SciPy, matplotlib under Python2.7.9

Source: Internet
Author: User
Tags install matplotlib

Objective:

The end of October 2015 began to learn python, has been tangled in the use of Python2 or Python3. Python3.0.0 released at the end of 2008, it has been 7 years, Python3 gradually replaced the low Python2. When I was learning Python's basic grammar, I installed the Python3.4.3, looking at the Little turtle's video, and the book is the basic Python tutorial.

Recently in the simulation with Python, need to install NumPy, SciPy, matplotlib and other scientific Computing library, friends recommend directly download a python (x, y), this software contains all scientific calculations to the library, eliminating the need to find a separate installation of each library, You can download python (x, y) directly, but the latest version of Python (x, y) does not support Python3, as it is difficult to install individual libraries separately. , the installation package has more than 800 m.

Because my two friends with Python (x, y), in order to complete the tasks assigned by the instructor, I have to switch to Python2.7.9, but do not want to install Python (x, y), he has more than 100 modules, the vast majority of me is useless, So I choose what module to use to install what module. Next you'll learn how to configure numpy,scipy and matplotlib.

After installing numpy,scipy and matplotlib, Python can become a very sharp scientific tool. The installation of the three libraries on the internet is very good, but most of the problems encountered by the people is not how to install, but after installation because of improper configuration, in use will always appear import xxx error errors and so on. I have been groping for a long time to find out how to properly configure.

First, install the Python2.7.9

Recommended just to start friends directly install Python3.4, I was forced to cooperate with others to Python2, now numpy,scipy and Matplotlib have supported Python3.4, but do not install the latest version, because the third party provides the library update is not so fast.

    • python:https://www.python.org/downloads/

Second, install NumPy, SciPy, matplotlib

Download Numpy,scipy,matplotlib This three library EXE, note that here is the EXE, because the use of matplotlib need to numpy support, so it is best to install NumPy and then install Matplotlib. :

    • Numpy:http://sourceforge.net/projects/numpy/files/numpy/1.9.2/
    • Scipy:http://sourceforge.net/projects/scipy/files/scipy/0.15.1/
    • Matplotlib:http://matplotlib.org/downloads.html

Need to pay attention to choose according to their own system Win32 or Win64, and note to Python2.7.9 corresponding, of course, if it is installed Python3.4 will download support 3.4 numpy, SciPy, Matplotlib. The installation path of Python will be automatically found at the time of installation, and next will be all right. Installed by default on \python27\lib\site-packages

Third, configuration Numpy,scipy,matplotlib

Installing only these three modules does not provide the ability to do the drawing, input in Python idle: Import matplotlib will prompt for errors. There are three reasons for the error:

    • Importerror:matplotlib requires Dateutil
    • Importerror:matplotlib requires pyparsing
    • No Module name Six

Before we solve these three problems, we need to install wheel (otherwise we cannot install the. whl file using the PIP command). Using the PIP command, it is recommended that you add the Pip.exe path to the environment variable (you can then delete the PIP in the environment variable) and PIP is installed under the \python27\scripts folder. Then execute:

Pip Install Wheel

If you do not configure the environment variable, you need to execute the above command from the CD to the \python27\scripts folder. The PIP will automatically download the installation wheel on the network. If you are prompted with an error or if you are not successfully installed, use the following command:

Python pip.exe Install wheel

I use the second statement to install the success, but the online blog is written by the use of the first, it may be a different version of it. After installing wheel we solve the three problems:

Open this link: http://www.lfd.uci.edu/~gohlke/pythonlibs/#six downloaded according to your own system and Python version: (You can press CTRL + F on the page to enter six, Dateutil, Pyparsing Find location)

    • Six-1.10.0-py2.py3-none-any.whl
    • Python_dateutil-2.4.2-py2.py3-none-any.whl
    • Pyparsing-2.0.3-py2-none-any.whl

Then copy these three. whl files to the \python27\scripts folder, do not copy the words need to enter the absolute path of the file at the time of installation, it is recommended to copy it first, and so on after the installation is complete and then deleted. Execute under CMD:

Pip Install SIX-1.10.0-PY2.PY3-NONE-ANY.WHL
Pip Install PYTHON_DATEUTIL-2.4.2-PY2.PY3-NONE-ANY.WHL
Pip Install PYPARSING-2.0.3-PY2-NONE-ANY.WHL

If you are prompted with an error, you can use the following command:

Python pip.exe Install SIX-1.10.0-PY2.PY3-NONE-ANY.WHL
Python pip.exe Install PYTHON_DATEUTIL-2.4.2-PY2.PY3-NONE-ANY.WHL
Python pip.exe Install PYPARSING-2.0.3-PY2-NONE-ANY.WHL

I use the following statement to install the success, but on the internet to see a lot of people using the above statement, so still choose according to their own situation.

Here we will configure the Numpy,scipy,matplotlib, with a test code:

1  fromMpl_toolkits.mplot3dImportAxes3d2 ImportMatplotlib.pyplot as Plt3  fromMatplotlibImportcm4 5Fig =plt.figure ()6Ax = FIG.GCA (projection='3d')7X, Y, Z = Axes3d.get_test_data (0.05)8Ax.plot_surface (X, Y, Z, Rstride=8, Cstride=8, alpha=0.3)9Cset = Ax.contour (X, Y, Z, zdir='Z', offset=-100, cmap=cm.coolwarm)TenCset = Ax.contour (X, Y, Z, zdir='x', offset=-40, cmap=cm.coolwarm) OneCset = Ax.contour (X, Y, Z, zdir='y', offset=40, cmap=cm.coolwarm) A  -Ax.set_xlabel ('X') -Ax.set_xlim (-40, 40) theAx.set_ylabel ('Y') -Ax.set_ylim (-40, 40) -Ax.set_zlabel ('Z') -Ax.set_zlim (-100, 100) +  -Plt.show ()

Installation and configuration of Numpy, SciPy, matplotlib under Python2.7.9

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.