Chainer has been dependent on Cython and h5py since 1.5.0 (see below for details and details).
pfnet/chainer v1.5.0 Unofficial tips for people who have trouble installing Chainer 1.5
For this reason, what was previously included in pip install chainer
has become a bit of a hassle. Especially in the Windows environment, the damage is large, so I will explain the installation on Windows.
The version of Python at the time of installation is 3.5 (Chainer already supports Python 3.5](https://github.com/pfnet/chainer/issues/526)!).
Cython is a mechanism for generating and using actual C / C ++ code from Python with some notations such as C / C ++ types. This gives you both simple Python notation and C / C ++ execution speed.
Introduction to Cython for those who are not satisfied with NumPy
However, since these compilations are necessary for the convenience of executing C / C ++ code, it is necessary to install them at the time of installation (specifically, C generated from the part written in Cython in Chainer). (Required to compile / C ++ code).
The C / C ++ compiler on Windows comes with Visual Studio, so install it. For Python3.5, it will be Visual Studio 2015 (Community is OK, but you need to check VC ++ at the time of installation).
There is a version of the compiler, and it is basically necessary to match this with the version of Visual Studio.
Using Microsoft Visual C with Python
Basically, the version of Visual C ++ is Python's MSC_VER minus 6. In the case of Python 3.5, the MSC version will be 19 as shown below, so the Visual C ++ version will be 14 because there is no 13 ..., that is, Visual Studio will be 2015 (probably one shift after that, so in the future I think you'll be subtracting 5 instead of 6).
>>> import sys
>>> sys.version
'3.5.0 |Continuum Analytics, Inc.| (default, Nov 7 2015, 13:25:22) [MSC v.1900
32 bit (Intel)]'
[Microsoft Visual C ++ / Product Version and Internal Version](https://ja.wikipedia.org/w/index.php?title=Microsoft_Visual_C%2B%2B§ion=10#.E8.A3.BD.E5.93.81.E3 .83.90.E3.83.BC.E3.82.B8.E3.83.A7.E3.83.B3.E3.81.A8.E5.86.85.E9.83.A8.E3.83.90.E3.83 .BC.E3.82.B8.E3.83.A7.E3.83.B3)
However, I don't want to install old Visual Studio to install it (Python2 series is long ago ...), so it is possible to use the latest version of the settings by editing the registry.
The vcvarsall
used for compilation is obtained in distutils.msvc9compiler.find_vcvarsall
, so it rewrites the following registry value referenced here.
I'm looking at the value of ProductDir
in it (eg (eg C: \ Program Files \ Microsoft Visual Studio 14.0 \ VC )).
If the above key and value do not exist, add a new key / value and set the VC ++ folder of Visual Studio that was actually installed.
distutils._msvccompiler.py
, but in HKEY_LOCAL_MACHINE \ Software \ Microsoft \ VisualStudio \ SxS \ VC7
, key name: Visual C ++ version number (example: 14.0), value: in the folder of Visual C ++ Become.Thank you for your hard work. The rest is easy.
Drop the dependent Numpy and h5py from the following and install them in the virtual environment (virtualenv). If you are using conda
, you can also go through conda.
Unofficial Windows Binaries for Python Extension Packages
The main dependent libraries are already installed, so you should be able to install them below.
pip install chainer
git clone
, move to that folder, and try python setup.py install
from python setup.py build
.Thank you for your hard work!
Recommended Posts