简体   繁体   English

为python 2和python 3安装scipy

[英]Install scipy for both python 2 and python 3

I used sudo apt-get install python-scipy to install scipy. 我使用sudo apt-get install python-scipy来安装scipy。 This put all the files in /usr/lib/python2.7.dist-packages/scipy . 这将所有文件放在/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. 我最好的猜测是它选择了那个位置,因为python 2.7是python的默认版本。 I also want to use scipy with python 3 however. 我也想使用scipy和python 3。 Does the package need to be rebuilt for python 3 or can I just point python 3 to the existing version? 是否需要为python 3重建包,还是只需将python 3指向现有版本?

I've tried using pip to install two parallel version, but I can't get the dependency libblas3 installed for my system. 我已经尝试使用pip来安装两个并行版本,但我无法为我的系统安装依赖libblas3

What's the best way to do this? 最好的方法是什么?

I'm on Debian Jessie. 我在Debian Jessie。

To install scipy for python3.x the on a debian-based distribution: 要在基于debian的发行版上安装python3.x的scipy:

sudo apt-get install python3-scipy

This corresponds to the python2.x equivalent: 这对应于python2.x等价物:

sudo apt-get install python-scipy

On a more platform-independent note, pip is the more standard way of installing python packages: 在一个更独立于平台的注释中, pip是安装python包的更标准方法:

    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: 为了确保使用正确的pip版本,您可以更加明确:

    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. 此外,我相信anaconda或更轻量级的miniconda旨在使安装具有复杂依赖关系的python包更加容易,而且它允许使用环境,使得更容易使用不兼容版本等进行多个配置。这将创建+使用与系统上的二进制文件不同的python二进制文件。

One would then install scipy using the command conda: 然后使用命令conda安装scipy:

conda install scipy

If installing scipy for a specific version you would create an environment with that python version: 如果为特定版本安装scipy,您将创建具有该python版本的环境:

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. 也可以在conda环境中使用pip与conda python包一起使用,但我会确保你使用conda安装pip以避免冲突。 An added benefit when installing conda for a user, is that you don't have to add the --user flag when installing with pip. 为用户安装conda时的一个额外好处是,在使用pip安装时不必添加--user标志。

如果使用apt-get找不到python3-scipy你可以使用pip为python3安装它,你只需要确保你使用pip3(如果你没有它apt install python3-pip

pip3 install --user scipy

您可能想尝试使用pip3 install scipy

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM