Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Install scipy for both python 2 and python 3

I used sudo apt-get install python-scipy to install scipy. This put all the files in /usr/lib/python2.7.dist-packages/scipy. My best guess is it chose that location because python 2.7 was the default version of python. I also want to use scipy with python 3 however. Does the package need to be rebuilt for python 3 or can I just point python 3 to the existing version?

I've tried using pip to install two parallel version, but I can't get the dependency libblas3 installed for my system.

What's the best way to do this?

I'm on Debian Jessie.

like image 208
ericksonla Avatar asked Feb 02 '17 22:02

ericksonla


Video Answer


2 Answers

To install scipy for python3.x the on a debian-based distribution:

sudo apt-get install python3-scipy

This corresponds to the python2.x equivalent:

sudo apt-get install python-scipy

On a more platform-independent note, pip is the more standard way of installing python packages:

    pip install --user scipy #pip install using default python version

To make sure you are using the right pip version you can always be more explicit:

    pip2 install --user scipy  # install using python2
    pip3 install --user scipy  # install using python3

Also, I believe anaconda or the more lightweight miniconda were intended to make installation of python packages with complex dependencies more easy, plus it allows for using an environment, making it easier to have several configurations with non-compatible versions etc. This would create+use a python binary different from the one on your system though.

One would then install scipy using the command conda:

conda install scipy

If installing scipy for a specific version you would create an environment with that python version:

conda create -n my_environment_name python=3 scipy

One could also use pip inside a conda environment alongside conda python packages, but I would make sure that you are using pip installed using conda to avoid conflicts. An added benefit when installing conda for a user, is that you don't have to add the --user flag when installing with pip.

like image 69
M.T Avatar answered Oct 19 '22 04:10

M.T


If you can't find python3-scipy using apt-get you can use pip to install it for python3, you just have to make sure you use pip3 (if you don't have it apt install python3-pip

pip3 install --user scipy
like image 3
Orange Avatar answered Oct 19 '22 04:10

Orange