Install scipy for both python 2 and python 3

ぃ、小莉子 提交于 2020-11-28 08:35:52

问题


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.


回答1:


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.




回答2:


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



回答3:


You may want to try with pip3 install scipy



来源:https://stackoverflow.com/questions/42013132/install-scipy-for-both-python-2-and-python-3

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!