NumPy, SciPy, matplotlib installation and configuration in Python

Source: Internet
Author: User
Tags install 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. The following is a detailed installation and configuration process.

1. Install Python, here choose 2.7 or 3.4 is OK, but recommended to use 2.7, after all, the current tutorial is mostly based on 2.7, 3.4 and 2.7 of the syntax is slightly different, in order to avoid the trouble of grammatical errors, or recommend that you use 2.7. is: https://www.python.org/downloads/

2. Download Numpy,scipy,matplotlib 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

where NumPy and scipy do not have 32 and 64-bit differences, matplotlib need to choose 32-bit and 64-bit according to their system. Again, these three libraries must download the corresponding version of the EXE. Once the download is complete, they will automatically find the path of the python you installed before, and the next is the end of the line.

3. After the 2nd step installation is complete, you can run it on the Matplotlib examples page (http://matplotlib.org/examples/index.html) copy code, and you will see an error. Here's the mistake, there are roughly three of them:

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

4. Solve the No module name six problem, the solution is very simple. Copy your installation path: Python27/lib/site-packages/scipy/lib in six.py,six.pyc,six.pyo three files to your installation path: Python27/lib/site-packages, The problem is solved. How not yet, please remember this address ( very important ): http://www.lfd.uci.edu/~gohlke/pythonlibs/
Then download this file: SIX?1.9.0?PY2.PY3?NONE?ANY.WHL, after downloading, use CMD to enter the directory where the file is located (Dos command: cd/d XX:/XXX/SIX?1.9.0?PY2.PY3?NONE?ANY.WHL Paste the path of your own six file into DOS and then enter the command: Pip install SIX-1.9.0-PY2.PY3-NONE-ANY.WHL, and so on, the DOS command runs out, six does not exist problem solved. The operation diagram is as follows:

5. Solve the Importerror:matplotlib requires dateutil problem, as in the 4th step, download PYTHON_DATEUTIL?2.4.2?PY2.PY3?NONE?ANY.WHL, then pip Install to solve the problem. The operation is as follows:

6. Solve importerror:matplotlib requires pyparsing problem, as before, download Pyparsing?2.0.3?py2?none? ANY.WHL (choose the corresponding version, here is the difference between 2 and 3) and then use the PIP install installation is OK. The operation is as follows:

In this way, all the configuration is completed and can happily use matplotlib for scientific drawing and calculation. Another reminder,Python2.7 and Python3.4 do not coexist , co-existence when the installation of these libraries will appear inexplicably wrong, how can not, recommend just use Python2.7,. Finally, a drawing code from Matplotlib is included:

From Mpl_toolkits.mplot3dImport Axes3dImport Matplotlib.pyplotAs PltFrom MatplotlibImport cmfig = plt.figure () ax = FIG.GCA (projection=' 3d ') X, Y, Z = Axes3d.get_test_data (0.05) Ax.plot_surface (X, Y, Z, rstride=8, Cstride=8, Alpha=0.3) Cset = Ax.contour (X, Y, Z, zdir= ' z ', Offset=-100, Cmap=cm.coolwarm) Cset = Ax.contour (X, Y, Z, Zdir= ' X ', Offset=-40, Cmap=cm.coolwarm ) Cset = Ax.contour (X, Y, Z, Zdir= ' Y ', Offset=40, Cmap=cm.coolwarm ) Ax.set_xlabel ( ' X ') Ax.set_xlim (-40, 40) Ax.set_ylabel ( ' Y ') Ax.set_ylim (- 40, 40) Ax.set_zlabel ( ' Z ') ax.set_ Zlim (-100, 100) plt.show () 

NumPy, SciPy, matplotlib installation and configuration in Python

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.