Python3, how to install numpy on CentOS 7?

24,114

They should come pre-compiled with Centos OS, so try with:

sudo yum install numpy scipy.

So you have two option fist one is installing it system wide, like I mentioned they are pre-compiled with Centos OS, so you can Install the complete scipy packages with numpy like this:

sudo yum install python-numpy python-scipy python-matplotlib ipython ipython-notebook python-pandas python-sympy python-nose

Or you can use pip for the installation, like this:

python -m pip install --user numpy scipy matplotlib ipython jupyter pandas sympy nose

Please read the official docs from scipy organization on how to install all the packages on you system.

NOTE:

You are right that system wide installation will install it only for python2.7, so to use it for python3.5 you will install via pip, so do this:

sudo python3 -m pip install --upgrade pip

sudo python3 -m pip install --user numpy scipy matplotlib ipython jupyter pandas sympy nose

and I suggest that you install all of this packages, after the installation I've opened my terminal and I've did this:

copser@copser-LIFEBOOK-S751:~$ python3.5
Python 3.5.2 (default, Sep 14 2017, 22:51:06) 
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy
>>> import numpy as np
>>> import numpy.f2py as myf2py
>>> 

as you can see I've imported numpy inside python3.5.2 and it is working, I'm using Ubuntu 16.04 it should be the same on Centos OS.

Share:
24,114
DavideChicco.it
Author by

DavideChicco.it

Machine learning & biomedical informatics University of Toronto Toronto, Ontario, Canada http://www.davidechicco.it davidechicco(AT)davidechicco.it

Updated on November 16, 2020

Comments

  • DavideChicco.it
    DavideChicco.it over 3 years

    I'm working with Python 3.5.1 on a computer having CentOS Linux release 7.3.1611 (Core) operating system.

    I have to install the numpy package.

    I tried to follow these instructions, by running the command:

    sudo yum -y install python34-setuptools
    

    Unfortunately, I got the following error:

    Transaction check error:
      file /usr/lib64/libpython3.so from install of python34-libs-3.4.5-4.el7.x86_64 conflicts with file from package python3-libs-3.3.2-12.el7.nux.x86_64
    

    Any idea on how to solve this problem? Thanks

    EDIT: On my machine, I have both Python2.7 and Python3.5, and I want to keep them both

    • Robbie Milejczak
      Robbie Milejczak over 6 years
      have you tried sudo yum install python3-numpy? Package name might be different but that's how I installed it on Ubuntu via aptitude
    • StegSchreck
      StegSchreck over 6 years
      would don't you install it via pip?
    • Robbie Milejczak
      Robbie Milejczak over 6 years
      @StegSchreck on Linux systems the native package manager is preferred, unless you need to install to a specific project or get a previous version of a package
    • Loïc
      Loïc over 6 years
    • StegSchreck
      StegSchreck over 6 years
      @RobbieMilejczak, if you maintain multiple python projects on the same developer machine, I would prefer to use python's virtualenv and a requirements.txt for each project. This can then be shipped together with the project, which makes tracking the requirements and their versions a lot easier.
    • Robbie Milejczak
      Robbie Milejczak over 6 years
      @Loïc he referenced that question in the comment and specifically said that solution did not help him
    • Robbie Milejczak
      Robbie Milejczak over 6 years
      @StegSchreck yeah I know like I said unless you need to install to a specific project. I was just answering your question not trying to argue about they are both valid approaches depending on your needs
    • StegSchreck
      StegSchreck over 6 years
      @RobbieMilejczak, no worries, I just tried to give more aspects for my comment. Choose whatever suits your case best.
    • Loïc
      Loïc over 6 years
      @RobbieMilejczak he did show the command he ran. He didn't follow the nice answer, which is the one with the most upvotes.
    • Loïc
      Loïc over 6 years
    • DavideChicco.it
      DavideChicco.it over 6 years
      That worked, this question can be closed. Thanks
    • Loïc
      Loïc over 6 years
      I knew it ;) please remember to upvote the solution that worked for you.
  • DavideChicco.it
    DavideChicco.it over 6 years
    Thanks but it did not work. I think it installed numpy and scipy on Python2
  • copser
    copser over 6 years
    @DavideChicco.it that is correct, so just use pip for installation, check out my edited answer.