【问题标题】:Installing SciPy with pip使用 pip 安装 SciPy
【发布时间】:2011-01-13 21:18:38
【问题描述】:

可以使用pip install numpy 安装NumPypip

SciPy 有类似的可能性吗? (执行pip install scipy 不起作用。)


更新

现在可以使用 pip 安装包 SciPy!

【问题讨论】:

  • 您可能想重新考虑接受的答案(也许是诺克斯的?)。我不认为通过 git 安装应该是首选方法! :)
  • 又相关了,因为最后几个版本不能简单pip install

标签: python installation scipy pip


【解决方案1】:

您也可以在带有 python 3.6 python -m pip install scipy 的 windows 中使用它

【讨论】:

    【解决方案2】:

    答案是肯定的。

    首先你可以轻松安装 numpy 使用命令:

    pip install numpy
    

    那你应该安装scipy需要的mkl,可以下载here

    下载完file_name.whl后安装

    C:\Users\****\Desktop\a> pip install mkl_service-1.1.2-cp35-cp35m-win32.whl
    Processing c:\users\****\desktop\a\mkl_service-1.1.2-cp35-cp35m-win32.whl 
    Installing collected packages: mkl-service    
    Successfully installed mkl-service-1.1.2
    

    然后在同一个网站你可以下载scipy-0.18.1-cp35-cp35m-win32.whl

    注意:根据你的python版本下载file_name.whl,如果你的python版本是32bit python3.5你应该下载这个,“win32”是你的python版本,不是你的操作系统版本。

    然后像这样安装file_name.whl:

    C:\Users\****\Desktop\a>pip install scipy-0.18.1-cp35-cp35m-win32.whl
    Processing c:\users\****\desktop\a\scipy-0.18.1-cp35-cp35m-win32.whl
    Installing collected packages: scipy
    Successfully installed scipy-0.18.1
    

    那么只有一件事要做:注释掉特定的行,否则输入命令“import scipy”时会出现错误消息。

    所以注释掉这一行

    from numpy._distributor_init import NUMPY_MKL  # requires numpy+mkl
    

    在这个文件中:your_own_path\lib\site-packages\scipy__init__.py

    然后你可以使用 SciPy :)

    Here 告诉你更多关于最后一步的信息。

    Here 是类似问题的类似回答者。

    【讨论】:

    • @Tonechas 这个怎么样?
    【解决方案3】:

    除了所有这些答案, 如果您在 64 位机器上安装 32 位的 python,则无论您的机器如何,都必须下载 32 位的 scipy。 http://www.lfd.uci.edu/~gohlke/pythonlibs/ 在上面的 URL 中你可以下载包,命令是:pip install

    【讨论】:

      【解决方案4】:
      1. 安装python-3.4.4
      2. scipy-0.15.1-win32-superpack-python3.4
      3. 应用以下推荐文档
      py -m pip install --upgrade pip
      py -m pip install numpy
      py -m pip install matplotlib
      py -m pip install scipy
      py -m pip install scikit-learn
      

      【讨论】:

        【解决方案5】:

        我尝试了以上所有方法,但对我没有任何帮助。这解决了我所有的问题:

        pip install -U numpy
        
        pip install -U scipy
        

        注意pip install-U 选项要求升级包。如果没有它,如果软件包已经安装,pip 会通知你并退出而不做任何事情。

        【讨论】:

          【解决方案6】:

          对于 gentoo,它位于主存储库中: emerge --ask scipy

          【讨论】:

            【解决方案7】:

            在 Fedora 上,这是可行的:

            sudo yum install -y python-pip
            sudo yum install -y lapack lapack-devel blas blas-devel 
            sudo yum install -y blas-static lapack-static
            sudo pip install numpy
            sudo pip install scipy
            

            如果您在下载时遇到任何public key 错误,请将--nogpgcheck 作为参数添加到yum,例如: yum --nogpgcheck install blas-devel

            在 Fedora 23 之后,使用 dnf 而不是 yum

            【讨论】:

            • 在我的虚拟环境中,我将建议解决方案的最后两行更改为以下行: sudo pip install --upgrade pip sudo pip install -U numpy sudo pip install -U scipy
            【解决方案8】:

            要在 Windows 上安装 scipy,请按照以下说明操作:-

            第 1 步:点击此链接 http://www.lfd.uci.edu/~gohlke/pythonlibs/#scipy 下载 scipy .whl 文件(例如 scipy-0.17.0-cp34-none-win_amd64.whl)。

            步骤 2:从命令提示符 (cd folder-name) 转到下载文件所在的目录。

            步骤 3:运行此命令:

            pip install scipy-0.17.0-cp27-none-win_amd64.whl
            

            【讨论】:

            • 只有这个选项在 Windows 上对我有帮助
            • 此选项在 Windows7 Cygwin 64 位上对我不起作用:scipy-0.17.1-cp27-cp27m-win_amd64.whl 在此平台上不支持。
            • @Nik 我收到了同样的信息。我认为这是因为您的 Python 实例是 32 位的。下载和安装“scipy-0.18.1-cp27-cp27m-win32.whl”对我有用。
            • 这在 Windows 上对我有用,我需要使用来自 that site 的包重新安装 numpy,一切正常
            【解决方案9】:

            先决条件:

            sudo apt-get install build-essential gfortran libatlas-base-dev python-pip python-dev
            sudo pip install --upgrade pip
            

            实际包:

            sudo pip install numpy
            sudo pip install scipy
            

            可选包:

            sudo pip install matplotlib   OR  sudo apt-get install python-matplotlib
            sudo pip install -U scikit-learn
            sudo pip install pandas
            

            src

            【讨论】:

            • 注意:这是构建必不可少的:)
            • sudo pip install 不是通用答案应包含的模式。通常你想pip install 进入你的 virtualenv。
            • 这解决了我的问题,谢谢!对于 Mac 用户,libatlas-base-dev 随操作系统一起提供,gfortran 可以使用软件包安装 (https://gcc.gnu.org/wiki/GFortranBinariesMacOS)
            • 呼应 erikb85,应该养成sudo pip installing python 库的习惯。使用virtualenvvirtualenvwrapper。我通常的模式是sudo apt-get install python-pip,后跟sudo pip install virtualenvwrapper。之后 一切 进入 virtualenv。
            • 还要确保您有足够的内存(即您正在某些 VPS 上运行安装)并在需要时创建交换文件这种情况下的错误消息是这样的:c++: internal compiler error: Killed (program cc1plus) error: Command "c++ -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -fPIC -D__STDC_FORMAT_MACROS=1 -I/usr/lib/python2.7/dist-packages/numpy/core/include -I/usr/include/python2.7 -c scipy/sparse/sparsetools/csr_wrap.cxx -o build/temp.linux-x86_64-2.7/scipy/sparse/sparsetools/csr_wrap.o" failed with exit status 4
            【解决方案10】:

            在我的情况下,直到我还安装了以下软件包,它才起作用:libatlas-base-dev、gfortran

             sudo apt-get install libatlas-base-dev gfortran
            

            然后运行 ​​pip install scipy

            【讨论】:

              【解决方案11】:

              easy_install 的尝试表明他们的listing 在pip 搜索的Python Package Index 中存在问题。

              easy_install scipy
              Searching for scipy
              Reading http://pypi.python.org/simple/scipy/
              Reading http://www.scipy.org
              Reading http://sourceforge.net/project/showfiles.php?group_id=27747&package_id=19531
              Reading http://new.scipy.org/Wiki/Download
              

              然而,一切都没有丢失; pip 可以从 Subversion (SVN)、GitMercurialBazaar 存储库安装。 SciPy 使用 SVN:

              pip install svn+http://svn.scipy.org/svn/scipy/trunk/#egg=scipy
              

              更新(12-2012):

              pip install git+https://github.com/scipy/scipy.git
              

              由于 NumPy 是一个依赖项,因此也应该安装它。

              【讨论】:

              • 太棒了!它为我做了什么:pip install svn+http://svn.scipy.org/svn/scipy/trunk 请注意,在*.com/questions/651305 之后,您还可以使用:pip install http://svn.scipy.org/svn/scipy/!svn/bc/5839/trunk/ 选择一个给定的修订版(比如 5839,我认为这是最后一个稳定版本,0.7.1):pip install http://svn.scipy.org/svn/scipy/!svn/bc/5839/trunk/没有测试...
              • +1 表示长寿和稳健。两年后,这仍然适用于我在 OSX 10.8.2 和 python 2.7 上。标准pip install scipy 在fortan 编译期间失败(即使在成功brew install gfortranpip install numpy 之后)。 svn install 消除了@lokalhort 的github repo install 与python3 或@elaichi 的依赖apt-gets 的ubuntu。
              • 大概这意味着你得到了最前沿的 scipy 而不是最新的稳定版本。
              • 对我不起作用。但这似乎是一个很好的解决方案。我想,我还有一些其他问题,这就是为什么这个解决方案不起作用。
              【解决方案12】:

              Ubuntu 插件(Ubuntu 10.04 LTS (Lucid Lynx)):

              仓库移动了,但是一个

              pip install -e git+http://github.com/scipy/scipy/#egg=scipy
              

              我失败了...通过以下步骤,它终于成功了(在虚拟环境中以 root 身份,其中python3 是 Python 3.2.2 的链接): 安装 Ubuntu 依赖项(参见 elaichi),克隆 NumPy 和 SciPy:

              git clone git://github.com/scipy/scipy.git scipy
              
              git clone git://github.com/numpy/numpy.git numpy
              

              构建 NumPy(在 numpy 文件夹中):

              python3 setup.py build --fcompiler=gnu95
              

              安装 SciPy(在 scipy 文件夹中):

              python3 setup.py install
              

              【讨论】:

                【解决方案13】:

                如果我首先将 BLAS、LAPACK 和 GCC Fortran 作为系统包安装(我使用的是Arch Linux),我可以通过以下方式安装 SciPy:

                pip install scipy
                

                【讨论】:

                • 如何安装 blas? “pip install blas”和“apt-get install blas”对我来说失败了。
                • @Eran blas 是一个 archlinux 包。所以你可以通过 pacman -S blas 安装。
                【解决方案14】:

                对于 Arch Linux 用户:

                pip install --user scipy 需要安装以下 Arch 软件包:

                • gcc-fortran
                • blas
                • lapack

                【讨论】:

                • 很高兴知道,但这会更好地作为对@user437730 答案的编辑或评论。
                • 如何安装这些软件包?即 gcc-fortran、blas、lapack
                【解决方案15】:

                在 Ubuntu 10.04 (Lucid) 中,我可以在安装一些依赖项后成功 pip install scipy(在 virtualenv 中),特别是:

                $ sudo apt-get install libamd2.2.0 libblas3gf libc6 libgcc1 libgfortran3 liblapack3gf libumfpack5.4.0 libstdc++6 build-essential gfortran libatlas-sse2-dev python-all-dev
                

                【讨论】:

                • 现在是 'libatlas-base-dev',而不是 'libatlas-sse2-dev'
                • $ sudo apt-get install libamd2.2.0 libblas3gf libc6 libgcc1 libgfortran3 liblapack3gf libumfpack5.4.0 libstdc++6 build-essential gfortran libatlas-dev libatlas3-base python python-all-dev gcc g++ libblas-dev liblapack-dev
                • 在 ubuntu 12.04 上:sudo aptitude install python-scipy
                • 如果你想使用最新版本的 scipy 最好是 sudo apt-get build-dep python-scipy 然后从 pip 安装 scipy。