install.rst 5.7 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177
:orphan:

.. _install:

Installation
------------

Using setuptools
~~~~~~~~~~~~~~~~

To obtain the latest released version of statsmodels using pip

    pip install -U statsmodels

Or follow `this link to our PyPI page <https://pypi.python.org/pypi/statsmodels>`__, download
the wheel or source and install.

Statsmodels is also available in through conda provided by
`Anaconda <https://www.continuum.io/downloads>`__. The latest release can
be installed using

    conda install -c conda-forge statsmodels

Obtaining the Source
~~~~~~~~~~~~~~~~~~~~

We do not release very often but the master branch of our source code is 
usually fine for everyday use. You can get the latest source from our 
`github repository <https://github.com/statsmodels/statsmodels>`__. Or if you
have git installed::

    git clone git://github.com/statsmodels/statsmodels.git

If you want to keep up to date with the source on github just periodically do::

    git pull

in the statsmodels directory.

Installation from Source
~~~~~~~~~~~~~~~~~~~~~~~~

You will need a C compiler installed to build statsmodels. If you are building
from the github source and not a source release, then you will also need
Cython. You can follow the instructions below to get a C compiler setup for Windows.

Linux
^^^^^

Once you have obtained the source, you can do (with appropriate permissions)::

    python setup.py install

Or::

    python setup.py build
    python setup.py install

Windows
^^^^^^^

It is strongly recommended to use 64-bit Python if possible.

Python 2.7
~~~~~~~~~~
Obtain
`Microsoft Visual C++ Compiler for Python 2.7 <https://www.microsoft.com/en-gb/download/details.aspx?id=44266>`__
and then install using

    python setup.py install

Python 3.5
~~~~~~~~~~
Download and install the most recent version of
`Visual Studio Community Edition <https://www.visualstudio.com/vs/community/>`__
and then install using

    python setup.py install


32-bit or other versions of Python
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
You can build 32-bit version of the code on windows using mingw32.

First, get and install `mingw32 <http://www.mingw.org/>`__. Then, you'll need to edit distutils.cfg. This is usually found somewhere like C:\Python27\Lib\distutils\distutils.cfg. Add these lines::

    [build]
    compiler=mingw32

Then in the statsmodels directory do::

    python setup.py build
    python setup.py install

OR

You can build 32-bit Microsoft SDK. Detailed instructions can be found on the
Cython wiki `here <https://github.com/cython/cython/wiki/CythonExtensionsOnWindows>`__.
The gist of these instructions follow. You will need to download the free
Windows SDK C/C++ compiler from Microsoft. You must use
the **Microsoft Windows SDK for Windows 7 and .NET Framework 3.5 SP1** to be
comptible with Python 2.7, 3.1, and 3.2. The link for the 3.5 SP1 version is

`https://www.microsoft.com/en-us/download/details.aspx?id=18950 <https://www.microsoft.com/en-us/download/details.aspx?id=18950>`__

For Python 3.3 and 3.4, you need to use the **Microsoft Windows SDK for Windows 7 and .NET Framework 4**,
available from

`https://www.microsoft.com/en-us/download/details.aspx?id=8279 <https://www.microsoft.com/en-us/download/details.aspx?id=8279>`__

For 7.0, get the ISO file GRMSDKX_EN_DVD.iso for AMD64. After you install this,
open the SDK Command Shell (Start -> All Programs ->
Microsoft Windows SDK v7.0 -> CMD Shell). CD to the statsmodels directory and type::

    set DISTUTILS_USE_SDK=1

To build a 64-bit application type::

    setenv /x64 /release

To build a 32-bit application type::

    setenv /x86 /release

The prompt should change colors to green. Then proceed as usual to install::

    python setup.py build
    python setup.py install

For 7.1, the instructions are exactly the same, except you use the download
link provided above and make sure you are using SDK 7.1.

If you want to accomplish the same without opening up the SDK CMD SHELL, then
you can use these commands at the CMD Prompt or in a batch file.::

    setlocal EnableDelayedExpansion
    CALL "C:\Program Files\Microsoft SDKs\Windows\v7.0\Bin\SetEnv.cmd" /x64 /release
    set DISTUTILS_USE_SDK=1

Replace `/x64` with `/x86` and `v7.0` with `v7.1` as needed.


Dependencies
~~~~~~~~~~~~

The current minimum dependencies are:

* `Python <https://www.python.org>`__ >= 2.7, including Python 3.4+
* `NumPy <http://www.scipy.org/>`__ >= 1.11
* `SciPy <http://www.scipy.org/>`__ >= 0.18
* `Pandas <http://pandas.pydata.org/>`__ >= 0.19
* `Patsy <https://patsy.readthedocs.io/en/latest/>`__ >= 0.4.0
* `Cython <http://cython.org/>`__ >= 0.24 is required to build the code from
  github but not from a source distribution.

Given the long release cycle, Statsmodels follows a loose time-based policy for
dependencies: minimal dependencies are lagged about one and a half to two
years. Our next planned update of minimum versions in `setup.py` is expected in
September 2018, when we will update to reflect Numpy >= 1.12 (released January
2017), Scipy >= 0.19 (released March 2017) and Pandas >= 0.20 (released May
2017).

Optional Dependencies
~~~~~~~~~~~~~~~~~~~~~

* `Matplotlib <http://matplotlib.org/>`__ >= 1.5 is needed for plotting
  functions and running many of the examples.
* If installed, `X-12-ARIMA <http://www.census.gov/srd/www/x13as/>`__ or
  `X-13ARIMA-SEATS <http://www.census.gov/srd/www/x13as/>`__ can be used
  for time-series analysis.
* `pytest <https://docs.pytest.org/en/latest/>`__ is required to run
  the test suite.
* `IPython <http://ipython.org>`__ >= 3.0 is required to build the
  docs locally or to use the notebooks.
* `joblib <http://pythonhosted.org/joblib/>`__ >= 0.9 can be used to accelerate distributed
  estimation for certain models.
* `jupyter <http://jupyter.org/>`__ is needed to run the notebooks.