Как установить библиотеку SciPy на Windows
Как то не очень понятно, как можно установить библиотеку ScyPy в операционной системе Windows?
Обновление: собранные wheels для Windows доступны для scipy-1.0+ на PyPI, то есть стандартную команду для установки можно использовать:
старая версия ответа:
Инструкция рекомендует, особенно на Windows, установить не один пакет, а сразу целый набор пакетов (Scientific Python distribution) такой как Anaconda.
Если вы хотите индивидуально numpy, scipy пакеты ставить, то инструкция рекомендует бинарные установщики с Christoph Gohlke сайта, которые доступны в виде бинарных wheel файлов, которые можно напрямую с помощью pip (c версией 8+) поставить:
Если у вас 64-битная Windows используйте wheel, которые в имени содержат amd64. Если у вас Python 3.6 стоит, то используйте wheel, который cp36m в названии имеет. Перед установкой scipy, необходимо поставить numpy.
Не смешивайте установку бинарных wheel файлов (таких как на Christoph Gohlke сайте) и установку через conda.
Там есть файлы с cp27, cp34, cp35, cp36. Интересно, что это обозначает?
Соглашения для имён wheel описаны в PEP-427.
Сами метки описаны в PEP-425.
Метки существуют, чтобы указать системы, где соответствующие бинарные пакеты должны работать.
cp36m—это ABI метка, которая указывает на CPython реализацию ( sys.implementation.name ), версию 3.6 ( sys.version[:3] ) как я выше упомянул, и m буква ( sys.abiflags ) в метке указывает на —with-pymalloc опцию см. PEP-3149.
И какие нужно выбирать для 32 битной Windows?
Метка платформы определяется distutils.util.get_platform() значением согласно PEP-425.
На Windows возможны три (значения из help(distutils.util.get_platform) ):
- win-amd64 (64bit Windows на AMD64 (aka x86_64, Intel64, EM64T)
- win-ia64 (64bit Windows на Itanium)
- win32 (все другие)
то есть для 32 битной Windows следует win32 метку выбрать.
InstallationВ¶
Installations methods include:
Methods differ in ease of use, coverage, maintenance of old versions, system-wide versus local environment use, and control. With pip or Anaconda’s conda, you can control the package versions for a specific project to prevent conflicts. Conda also controls non-Python packages, like MKL or HDF5. System package managers, like apt-get , install across the entire computer, often have older versions, and don’t have as many available versions. Source compilation is much more difficult but is necessary for debugging and development. If you don’t know which installation method you need or prefer, we recommend the Scientific Python Distribution Anaconda .
Scientific Python Distributions (recommended)В¶
Python distributions provide the language itself, along with the most commonly used packages and tools. These downloadable files require little configuration, work on almost all setups, and provide all the commonly used scientific python tools.
Anaconda works on Windows, Mac, and Linux, provides over 1,500 Python/R packages, and is used by over 15 million people. Anaconda is best suited to beginning users; it provides a large collection of libraries all in one.
For more advanced users who will need to install or upgrade regularly, Miniconda is a more suitable way to install the conda package manager.
Other options include:
WinPython: Another free distribution including scientific packages and the Spyder IDE; Windows only, but more actively maintained and supports the latest Python 3 versions.
Pyzo: A free distribution based on Anaconda and the IEP interactive development environment; Supports Linux, Windows, and Mac.
Installing via pipВ¶
Python comes with an inbuilt package management system, pip. Pip can install, update, or delete any official package.
You can install packages via the command line by entering:
We recommend using an user install, sending the —user flag to pip. pip installs packages for the local user and does not write to the system directories. Preferably, do not use sudo pip , as this combination can cause problems.
Pip accesses the Python Package Index, PyPI , which stores almost 200,000 projects and all previous releases of said projects. Because the repository keeps previous versions, you can pin to a version and not worry about updates causing conflicts. Pip can also install packages in local virtualenv, or virtual environment.
Install system-wide via a package managerВ¶
System package managers can install the most common Python packages. They install packages for the entire computer, often use older versions, and don’t have as many available versions.
Installing NumPy and SciPy on 64-bit Windows (with Pip)
I found out that it’s impossible to install NumPy/SciPy via installers on Windows 64-bit, that’s only possible on 32-bit. Because I need more memory than a 32-bit installation gives me, I need the 64-bit version of everything.
I tried to install everything via Pip and most things worked. But when I came to SciPy, it complained about missing a Fortran compiler. So I installed Fortran via MinGW/MSYS. But you can’t install SciPy right away after that, you need to reinstall NumPy. So I tried that, but now it doesn’t work anymore via Pip nor via easy_install . Both give these errors:
- There are a lot of errors about LNK2019 and LNK1120 ,.
- I get a lot of errors in the range of C : C2065, C2054 , C2085 , C2143`, etc. They belong together I believe.
- There is no Fortran linker found, but I have no idea how to install that, can’t find anything on it.
- And many more errors which are already out of the visible part of my cmd-windows.
The fatal error is about LNK1120 :
build\lib.win-amd64-2.7\numpy\linalg\lapack_lite.pyd : fatal error LNK1120: 7 unresolved externals error: Setup script exited with error: Command «C:\Users\me\AppData\Local\Programs\Common\Microsoft\Visual C++ for Python\9.0\VC\Bin\amd64\link.exe /DLL /nologo /INCREMENTAL:NO /LIBPATH:C:\BLAS /LIBPATH:C:\Python27\libs /LIBPATH:C:\Python27\PCbuild\amd64 /LIBPATH:build\temp.win-amd64-2.7 lapack.lib blas.lib /EXPORT:initlapack_lite build\temp.win-amd64-2.7\Release\numpy\linalg\lapack_litemodule.obj /OUT:build\lib.win-amd64-2.7\numpy\linalg\lapack_lite.pyd /IMPLIB:build\temp.win-amd64-2.7\Release\numpy\linalg\lapack_lite.lib /MANIFESTFILE:build\temp.win-amd64-2.7\Release\numpy\linalg\lapack_lite.pyd.manifest» failed with exit status 1120
What is the correct way to install the 64-bit versions NumPy and SciPy on a 64-bit Windows machine? Did I miss anything? Do I need to specify something somewhere? There is no information for Windows on these problems that I can find, only for Linux or Mac OS X, but they don’t help me as I can’t use their commands.