How To Install Python Package Numpy, Pandas, Scipy, Matplotlib On Windows, Mac And Linux

If you want to do data analysis in python, you always need to use python packages like Numpy, Pandas, Scipy and Matplotlib, etc. All those python packages are so powerful and useful to do Base N-dimensional array computing( Numpy ), Data structures & analysis ( Pandas ), scientific computing ( Scipy), and Comprehensive 2D Plotting ( Matplotlib ). But the first step is to install the related packages on your OS, this article will tell you how to install them on Windows, Mac, and Linux.

1. Install Numpy, Pandas, Scipy, Matplotlib With Anaconda.

Anaconda is a python edition that is used in the scientific areas, so if you install Anaconda, all the above packages will be installed automatically. So please read the article How To Install Anaconda On Linux, Windows, macOS Correctly to install anaconda first.

After installation, you can run command conda in a terminal to list above packages to make sure it has been installed correctly.

~$ conda list pandas
# packages in environment at /home/zhaosong/anaconda3:
#
# Name                    Version                   Build  Channel
pandas                    0.23.4           py37h04863e7_0

To list all installed anaconda packages, just run $ conda list.

Run $ conda -h to list the conda command help information.

If you want to remove/uninstall a package, run $ conda remove <package name>

2. Install Numpy, Pandas, Scipy, Matplotlib By PIP Command.

  1. First, make sure pip has been installed on your OS. If it is not installed, please refer article How To Install Python/Pip On Windows.
    ~$ pip --version
    pip 18.1 from /home/zhaosong/anaconda3/lib/python3.7/site-packages/pip (python 3.7)
    
  2. Run pip install command to install related packages.
    pip install numpy
    
    pip install pandas
    
    pip install scipy
    
    pip install matplotlib
    
    
  3. Run pip uninstall command to uninstall related packages.
    pip uninstall numpy
    
    pip uninstall pandas
    
    pip uninstall scipy
    
    pip uninstall matplotlib
  4. Run pip show command to display package install information.
    ~$ pip show pandas
    Name: pandas
    Version: 0.23.4
    Summary: Powerful data structures for data analysis, time series, and statistics
    Home-page: http://pandas.pydata.org
    Author: None
    Author-email: None
    License: BSD
    Location: /home/zhaosong/anaconda3/lib/python3.7/site-packages
    Requires: python-dateutil, pytz, numpy
    Required-by: seaborn, odo

3. How To Install Correct Numpy, Scipy, Matplotlib Package For Multiple Python Versions.

  1. I have 2 python versions installed on my Ubuntu Linux os, they are python 2.7 and python 3.8. The python 2.7 is a built-in python version when I installed ubuntu. And I install python 3.8 manually. Now I want to install the Scipy library on my Ubuntu Linux OS, and I find the below command in scipy.org, then I run the below command in a terminal.
    python -m pip install --user numpy scipy matplotlib ipython jupyter pandas sympy nose

    But when the above command execution complete, I found it only install the NumPy, Scipy, Matplotlib, iPython, etc for python 2.7. It does not install the packages for python 3.8 as I want, how can I resolve this issue? Thanks a lot.

  2. This is because the Ubuntu Linux installed python 2.7 by default, then the default pip command is also of python version 2.7. So when you run the python -m pip install --user numpy scipy matplotlib ipython jupyter pandas sympy nose command, it will use python 2.7’s pip command to install. To fix this issue, you need to first install the pip command for python 3.8 ( sudo apt-get install python3-pip ), and then run the pip3 command to install all the Scipy packages for python 3.8 ( python -m pip install --user numpy scipy matplotlib ipython jupyter pandas sympy nose ).
0 0 votes
Article Rating
Subscribe
Notify of
guest

This site uses Akismet to reduce spam. Learn how your comment data is processed.

0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x