<commit_before>************
Installation
************

Requirements
============

Astropy has the following strict requirements:

- `Python <http://www.python.org/>`_ 2.6 (>=2.6.5), 2.7, 3.3, or 3.4

  - Prior to Astropy v1.0 Python 3.1 and 3.2 are also supported.

- `Numpy`_ |minimum_numpy_version| or later

Astropy also depends on other packages for optional features:

- `h5py <http://h5py.org/>`_: To read/write
  :class:`~astropy.table.Table` objects from/to HDF5 files

- `BeautifulSoup <http://www.crummy.com/software/BeautifulSoup/>`_: To read
  :class:`~astropy.table.table.Table` objects from HTML files

- `PyYAML <http://pyyaml.org>`_: To read/write
  :class:`~astropy.table.Table` objects from/to the Enhanced CSV ASCII table format.

- `scipy`_: To power a variety of features (currently
  mainly cosmology-related functionality)

- `xmllint <http://www.xmlsoft.org/>`_: To validate VOTABLE XML files.

However, note that these only need to be installed if those particular features
are needed. Astropy will import even if these dependencies are not installed.

.. TODO: Link to the planned dependency checker/installer tool.

Installing Astropy
==================

Using pip
-------------

To install Astropy with `pip <http://www.pip-installer.org/en/latest/>`_, simply run::

    pip install --no-deps astropy

.. warning::

    Users of the Anaconda python distribution should follow the instructions
    for :ref:`anaconda_install`.

.. note::

    You will need a C compiler (e.g. ``gcc`` or ``clang``) to be installed (see
    `Building from source`_ below) for the installation to succeed.

.. note::

    The ``--no-deps`` flag is optional, but highly recommended if you already
    have Numpy installed, since otherwise pip will sometimes try to "help" you
    by upgrading your Numpy installation, which may not always be desired.

.. note::

    If you get a ``PermissionError`` this means that you do not have the
    required administrative access to install new packages to your Python
    installation.  In this case you may consider using the ``--user`` option
    to install the package into your home directory.  You can read more
    about how to do this in the `pip documentation
    <http://www.pip-installer.org/en/1.2.1/other-tools.html#using-pip-with-the-user-scheme>`_.

    Alternatively, if you intend to do development on other software that uses
    Astropy, such as an affiliated package, consider installing Astropy into a
    :ref:`virtualenv<using-virtualenv>`.

    Do **not** install Astropy or other third-party packages using ``sudo``
    unless you are fully aware of the risks.


.. _anaconda_install:

Anaconda python distribution
----------------------------

Astropy is installed by default with Anaconda. To update to the latest version
run::

    conda update astropy

.. note::

    There may be a delay of a day or two between when a new version of Astropy
    is released and when a package is available for Anaconda. You can check
    for the list of available versions with ``conda search astropy``.

.. note::

    Attempting to use ``pip`` to upgrade your installation of Astropy may result
    in a corrupted installation.


Binary installers
-----------------

Binary installers are available on Windows for Python 2.6, 2.7, and >= 3.3
at `PyPI <https://pypi.python.org/pypi/astropy>`_.

.. _testing_installed_astropy:


Testing an installed Astropy
----------------------------

The easiest way to test your installed version of astropy is running
correctly is to use the :ref:`astropy.test()` function::

    import astropy
    astropy.test()

The tests should run and print out any failures, which you can report at
the `Astropy issue tracker <http://github.com/astropy/astropy/issues>`_.

.. note::

    This way of running the tests may not work if you do it in the
    astropy source distribution.  See :ref:`sourcebuildtest` for how to
    run the tests from the source code directory, or :ref:`running-tests`
    for more details.

.. note::

    Running the tests this way is currently disabled in the IPython REPL due
    to conflicts with some common display settings in IPython.  Please run the
    Astropy tests under the standard Python command-line interpreter.



Building from source
====================

Prerequisites
-------------

You will need a compiler suite and the development headers for Python and
Numpy in order to build Astropy. On Linux, using the package manager for your
distribution will usually be the easiest route, while on MacOS X you will
need the XCode command line tools.

The `instructions for building Numpy from source
<http://docs.scipy.org/doc/numpy/user/install.html>`_ are also a good
resource for setting up your environment to build Python packages.

You will also need `Cython <http://cython.org/>`_ (v0.15 or later) and
`jinja2 <http://jinja.pocoo.org/docs/dev/>`_ installed
to build from source, unless you are installing a numbered release. (The
releases packages have the necessary C files packaged with them, and hence do
not require Cython.)

.. note::

    If you are using MacOS X, you will need to the XCode command line tools.
    One way to get them is to install `XCode
    <https://developer.apple.com/xcode/>`_. If you are using OS X 10.7 (Lion)
    or later, you must also explicitly install the command line tools. You can
    do this by opening the XCode application, going to **Preferences**, then
    **Downloads**, and then under **Components**, click on the Install button
    to the right of **Command Line Tools**.  Alternatively, on 10.7 (Lion) or
    later, you do not need to install XCode, you can download just the command
    line tools from https://developer.apple.com/downloads/index.action<commit_msg>Specify minimum required version of jinja2 in install docs<commit_after>************
Installation
************

Requirements
============

Astropy has the following strict requirements:

- `Python <http://www.python.org/>`_ 2.6 (>=2.6.5), 2.7, 3.3, or 3.4

  - Prior to Astropy v1.0 Python 3.1 and 3.2 are also supported.

- `Numpy`_ |minimum_numpy_version| or later

Astropy also depends on other packages for optional features:

- `h5py <http://h5py.org/>`_: To read/write
  :class:`~astropy.table.Table` objects from/to HDF5 files

- `BeautifulSoup <http://www.crummy.com/software/BeautifulSoup/>`_: To read
  :class:`~astropy.table.table.Table` objects from HTML files

- `PyYAML <http://pyyaml.org>`_: To read/write
  :class:`~astropy.table.Table` objects from/to the Enhanced CSV ASCII table format.

- `scipy`_: To power a variety of features (currently
  mainly cosmology-related functionality)

- `xmllint <http://www.xmlsoft.org/>`_: To validate VOTABLE XML files.

However, note that these only need to be installed if those particular features
are needed. Astropy will import even if these dependencies are not installed.

.. TODO: Link to the planned dependency checker/installer tool.

Installing Astropy
==================

Using pip
-------------

To install Astropy with `pip <http://www.pip-installer.org/en/latest/>`_, simply run::

    pip install --no-deps astropy

.. warning::

    Users of the Anaconda python distribution should follow the instructions
    for :ref:`anaconda_install`.

.. note::

    You will need a C compiler (e.g. ``gcc`` or ``clang``) to be installed (see
    `Building from source`_ below) for the installation to succeed.

.. note::

    The ``--no-deps`` flag is optional, but highly recommended if you already
    have Numpy installed, since otherwise pip will sometimes try to "help" you
    by upgrading your Numpy installation, which may not always be desired.

.. note::

    If you get a ``PermissionError`` this means that you do not have the
    required administrative access to install new packages to your Python
    installation.  In this case you may consider using the ``--user`` option
    to install the package into your home directory.  You can read more
    about how to do this in the `pip documentation
    <http://www.pip-installer.org/en/1.2.1/other-tools.html#using-pip-with-the-user-scheme>`_.

    Alternatively, if you intend to do development on other software that uses
    Astropy, such as an affiliated package, consider installing Astropy into a
    :ref:`virtualenv<using-virtualenv>`.

    Do **not** install Astropy or other third-party packages using ``sudo``
    unless you are fully aware of the risks.


.. _anaconda_install:

Anaconda python distribution
----------------------------

Astropy is installed by default with Anaconda. To update to the latest version
run::

    conda update astropy

.. note::

    There may be a delay of a day or two between when a new version of Astropy
    is released and when a package is available for Anaconda. You can check
    for the list of available versions with ``conda search astropy``.

.. note::

    Attempting to use ``pip`` to upgrade your installation of Astropy may result
    in a corrupted installation.


Binary installers
-----------------

Binary installers are available on Windows for Python 2.6, 2.7, and >= 3.3
at `PyPI <https://pypi.python.org/pypi/astropy>`_.

.. _testing_installed_astropy:


Testing an installed Astropy
----------------------------

The easiest way to test your installed version of astropy is running
correctly is to use the :ref:`astropy.test()` function::

    import astropy
    astropy.test()

The tests should run and print out any failures, which you can report at
the `Astropy issue tracker <http://github.com/astropy/astropy/issues>`_.

.. note::

    This way of running the tests may not work if you do it in the
    astropy source distribution.  See :ref:`sourcebuildtest` for how to
    run the tests from the source code directory, or :ref:`running-tests`
    for more details.

.. note::

    Running the tests this way is currently disabled in the IPython REPL due
    to conflicts with some common display settings in IPython.  Please run the
    Astropy tests under the standard Python command-line interpreter.



Building from source
====================

Prerequisites
-------------

You will need a compiler suite and the development headers for Python and
Numpy in order to build Astropy. On Linux, using the package manager for your
distribution will usually be the easiest route, while on MacOS X you will
need the XCode command line tools.

The `instructions for building Numpy from source
<http://docs.scipy.org/doc/numpy/user/install.html>`_ are also a good
resource for setting up your environment to build Python packages.

You will also need `Cython <http://cython.org/>`_ (v0.15 or later) and
`jinja2 <http://jinja.pocoo.org/docs/dev/>`_ (v2.7 or later) installed
to build from source, unless you are installing a numbered release. (The
releases packages have the necessary C files packaged with them, and hence do
not require Cython.)

.. note::

    If you are using MacOS X, you will need to the XCode command line tools.
    One way to get them is to install `XCode
    <https://developer.apple.com/xcode/>`_. If you are using OS X 10.7 (Lion)
    or later, you must also explicitly install the command line tools. You can
    do this by opening the XCode application, going to **Preferences**, then
    **Downloads**, and then under **Components**, click on the Install button
    to the right of **Command Line Tools**.  Alternatively, on 10.7 (Lion) or
    later, you do not need to install XCode, you can download just the command
    line tools from https://developer.apple.com/downloads/index.action
{'fraction_non_alphanumeric': 0.10934393638170974, 'fraction_numerical': 0.007001469444204339, 'mean_word_length': 3.3942271173566274, 'pattern_counts': {'":': 0, '<': 31, '<?xml version=': 0, '>': 35, 'https://': 6, 'lorem ipsum': 0, 'www.': 10, 'xml': 4}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3256490', 'n_tokens_mistral': 3342, 'n_tokens_neox': 3153, 'n_words': 1478}