为python 2和python 3安装scipy [英] Install scipy for both python 2 and python 3

查看:55
本文介绍了为python 2和python 3安装scipy的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用 sudo apt-get install python-scipy 来安装scipy.这会将所有文件放在/usr/lib/python2.7.dist-packages/scipy 中.我最好的猜测是它选择了该位置,因为python 2.7是python的默认版本.我也想将scipy与python 3一起使用.是否需要针对python 3重建软件包,或者我可以仅将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?

我尝试使用pip安装两个并行版本,但无法为系统安装依赖项 libblas3 .

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?

我在Debian Jessie上.

I'm on Debian Jessie.

推荐答案

要在基于debian的发行版上为python3.x安装scipy:

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

sudo apt-get install python3-scipy

这对应于python2.x等效项:

This corresponds to the python2.x equivalent:

sudo apt-get install python-scipy

在更独立于平台的注释上, pip 是安装python软件包的更标准方式:

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

为确保您使用的是正确的pip版本,您可以始终更加明确:

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

此外,我相信anaconda或更轻巧的 miniconda 旨在通过以下方式安装python软件包:复杂的依赖关系更容易,而且它允许使用环境,从而使具有不兼容版本等的多种配置更加容易.尽管如此,这将创建+使用与系统上的Python二进制文件不同的python二进制文件.

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.

然后将使用命令conda安装scipy:

One would then install scipy using the command conda:

conda install scipy

如果为特定版本安装scipy,则将使用该python版本创建环境:

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

一个人也可以在conda环境中与conda python软件包一起使用pip,但是我要确保您使用的是通过conda安装的pip,以避免冲突.为用户安装conda时的另一个好处是,使用pip安装时不必添加-user 标志.

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.

这篇关于为python 2和python 3安装scipy的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆