We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Pip installing Nilearn 0.6.0a0 in Py2 envs
Not sure why, installing Nilearn 06.0a0 in a Python2environment does not raise an error. This is strange, since the wheels I build this time are not universal and I removed Python 2 tags. Maybe something was overlooked? Will look at this.

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `setup.py`
Content:
```
1 #! /usr/bin/env python
2 
3 descr = """A set of python modules for neuroimaging..."""
4 
5 import sys
6 import os
7 
8 from setuptools import setup, find_packages
9 
10 
11 def load_version():
12     """Executes nilearn/version.py in a globals dictionary and return it.
13 
14     Note: importing nilearn is not an option because there may be
15     dependencies like nibabel which are not installed and
16     setup.py is supposed to install them.
17     """
18     # load all vars into globals, otherwise
19     #   the later function call using global vars doesn't work.
20     globals_dict = {}
21     with open(os.path.join('nilearn', 'version.py')) as fp:
22         exec(fp.read(), globals_dict)
23 
24     return globals_dict
25 
26 
27 def is_installing():
28     # Allow command-lines such as "python setup.py build install"
29     install_commands = set(['install', 'develop'])
30     return install_commands.intersection(set(sys.argv))
31 
32 
33 # Make sources available using relative paths from this file's directory.
34 os.chdir(os.path.dirname(os.path.abspath(__file__)))
35 
36 _VERSION_GLOBALS = load_version()
37 DISTNAME = 'nilearn'
38 DESCRIPTION = 'Statistical learning for neuroimaging in Python'
39 with open('README.rst') as fp:
40     LONG_DESCRIPTION = fp.read()
41 MAINTAINER = 'Gael Varoquaux'
42 MAINTAINER_EMAIL = 'gael.varoquaux@normalesup.org'
43 URL = 'http://nilearn.github.io'
44 LICENSE = 'new BSD'
45 DOWNLOAD_URL = 'http://nilearn.github.io'
46 VERSION = _VERSION_GLOBALS['__version__']
47 
48 
49 if __name__ == "__main__":
50     if is_installing():
51         module_check_fn = _VERSION_GLOBALS['_check_module_dependencies']
52         module_check_fn(is_nilearn_installing=True)
53 
54     install_requires = \
55         ['%s>=%s' % (mod, meta['min_version'])
56             for mod, meta in _VERSION_GLOBALS['REQUIRED_MODULE_METADATA']
57             if not meta['required_at_installation']]
58 
59     setup(name=DISTNAME,
60           maintainer=MAINTAINER,
61           maintainer_email=MAINTAINER_EMAIL,
62           description=DESCRIPTION,
63           license=LICENSE,
64           url=URL,
65           version=VERSION,
66           download_url=DOWNLOAD_URL,
67           long_description=LONG_DESCRIPTION,
68           zip_safe=False,  # the package can run out of an .egg file
69           classifiers=[
70               'Intended Audience :: Science/Research',
71               'Intended Audience :: Developers',
72               'License :: OSI Approved',
73               'Programming Language :: C',
74               'Programming Language :: Python',
75               'Topic :: Software Development',
76               'Topic :: Scientific/Engineering',
77               'Operating System :: Microsoft :: Windows',
78               'Operating System :: POSIX',
79               'Operating System :: Unix',
80               'Operating System :: MacOS',
81               'Programming Language :: Python :: 3.5',
82               'Programming Language :: Python :: 3.6',
83               'Programming Language :: Python :: 3.7',
84           ],
85           packages=find_packages(),
86           package_data={'nilearn.datasets.data': ['*.nii.gz', '*.csv', '*.txt'
87                                                   ],
88                         'nilearn.datasets.data.fsaverage5': ['*.gz'],
89                         'nilearn.surface.data': ['*.csv'],
90                         'nilearn.plotting.data.js': ['*.js'],
91                         'nilearn.plotting.data.html': ['*.html'],
92                         'nilearn.plotting.glass_brain_files': ['*.json'],
93                         'nilearn.tests.data': ['*'],
94                         'nilearn.image.tests.data': ['*.mgz'],
95                         'nilearn.surface.tests.data': ['*.annot', '*.label'],
96                         'nilearn.datasets.tests.data': ['*.*'],
97                         'nilearn.datasets.description': ['*.rst'],
98                         'nilearn.reporting.data.html': ['*.html']},
99           install_requires=install_requires,)
100
```

Path: `nilearn/version.py`
Content:
```
1 # *- encoding: utf-8 -*-
2 """
3 nilearn version, required package versions, and utilities for checking
4 """
5 # Author: Loic Esteve, Ben Cipollini
6 # License: simplified BSD
7 
8 # PEP0440 compatible formatted version, see:
9 # https://www.python.org/dev/peps/pep-0440/
10 #
11 # Generic release markers:
12 # X.Y
13 # X.Y.Z # For bugfix releases
14 #
15 # Admissible pre-release markers:
16 # X.YaN # Alpha release
17 # X.YbN # Beta release
18 # X.YrcN # Release Candidate
19 # X.Y # Final release
20 #
21 # Dev branch marker is: 'X.Y.dev' or 'X.Y.devN' where N is an integer.
22 # 'X.Y.dev0' is the canonical version of 'X.Y.dev'
23 #
24 __version__ = '0.6.0a'
25 
26 _NILEARN_INSTALL_MSG = 'See %s for installation information.' % (
27     'http://nilearn.github.io/introduction.html#installation')
28 
29 # This is a tuple to preserve order, so that dependencies are checked
30 #   in some meaningful order (more => less 'core').
31 REQUIRED_MODULE_METADATA = (
32     ('numpy', {
33         'min_version': '1.11',
34         'required_at_installation': True,
35         'install_info': _NILEARN_INSTALL_MSG}),
36     ('scipy', {
37         'min_version': '0.19',
38         'required_at_installation': True,
39         'install_info': _NILEARN_INSTALL_MSG}),
40     ('sklearn', {
41         'min_version': '0.19',
42         'required_at_installation': True,
43         'install_info': _NILEARN_INSTALL_MSG}),
44     ('joblib', {
45         'min_version': '0.11',
46         'required_at_installation': True,
47         'install_info': _NILEARN_INSTALL_MSG}),
48     ('nibabel', {
49         'min_version': '2.0.2',
50         'required_at_installation': False}))
51 
52 OPTIONAL_MATPLOTLIB_MIN_VERSION = '2.0'
53 
54 
55 def _import_module_with_version_check(
56         module_name,
57         minimum_version,
58         install_info=None):
59     """Check that module is installed with a recent enough version
60     """
61     from distutils.version import LooseVersion
62 
63     try:
64         module = __import__(module_name)
65     except ImportError as exc:
66         user_friendly_info = ('Module "{0}" could not be found. {1}').format(
67             module_name,
68             install_info or 'Please install it properly to use nilearn.')
69         exc.args += (user_friendly_info,)
70         # Necessary for Python 3 because the repr/str of ImportError
71         # objects was changed in Python 3
72         if hasattr(exc, 'msg'):
73             exc.msg += '. ' + user_friendly_info
74         raise
75 
76     # Avoid choking on modules with no __version__ attribute
77     module_version = getattr(module, '__version__', '0.0.0')
78 
79     version_too_old = (not LooseVersion(module_version) >=
80                        LooseVersion(minimum_version))
81 
82     if version_too_old:
83         message = (
84             'A {module_name} version of at least {minimum_version} '
85             'is required to use nilearn. {module_version} was found. '
86             'Please upgrade {module_name}').format(
87                 module_name=module_name,
88                 minimum_version=minimum_version,
89                 module_version=module_version)
90 
91         raise ImportError(message)
92 
93     return module
94 
95 
96 def _check_module_dependencies(is_nilearn_installing=False):
97     """Throw an exception if nilearn dependencies are not installed.
98 
99     Parameters
100     ----------
101     is_nilearn_installing: boolean
102         if True, only error on missing packages that cannot be auto-installed.
103         if False, error on any missing package.
104 
105     Throws
106     -------
107     ImportError
108     """
109 
110     for (module_name, module_metadata) in REQUIRED_MODULE_METADATA:
111         if not (is_nilearn_installing and
112                 not module_metadata['required_at_installation']):
113             # Skip check only when installing and it's a module that
114             # will be auto-installed.
115             _import_module_with_version_check(
116                 module_name=module_name,
117                 minimum_version=module_metadata['min_version'],
118                 install_info=module_metadata.get('install_info'))
119
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/nilearn/version.py b/nilearn/version.py
--- a/nilearn/version.py
+++ b/nilearn/version.py
@@ -21,7 +21,7 @@
 # Dev branch marker is: 'X.Y.dev' or 'X.Y.devN' where N is an integer.
 # 'X.Y.dev0' is the canonical version of 'X.Y.dev'
 #
-__version__ = '0.6.0a'
+__version__ = '0.6.0b'
 
 _NILEARN_INSTALL_MSG = 'See %s for installation information.' % (
     'http://nilearn.github.io/introduction.html#installation')
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -96,4 +96,6 @@
                         'nilearn.datasets.tests.data': ['*.*'],
                         'nilearn.datasets.description': ['*.rst'],
                         'nilearn.reporting.data.html': ['*.html']},
-          install_requires=install_requires,)
+          install_requires=install_requires,
+          python_requires='>=3.5',
+          )

{"golden_diff": "diff --git a/nilearn/version.py b/nilearn/version.py\n--- a/nilearn/version.py\n+++ b/nilearn/version.py\n@@ -21,7 +21,7 @@\n # Dev branch marker is: 'X.Y.dev' or 'X.Y.devN' where N is an integer.\n # 'X.Y.dev0' is the canonical version of 'X.Y.dev'\n #\n-__version__ = '0.6.0a'\n+__version__ = '0.6.0b'\n \n _NILEARN_INSTALL_MSG = 'See %s for installation information.' % (\n     'http://nilearn.github.io/introduction.html#installation')\ndiff --git a/setup.py b/setup.py\n--- a/setup.py\n+++ b/setup.py\n@@ -96,4 +96,6 @@\n                         'nilearn.datasets.tests.data': ['*.*'],\n                         'nilearn.datasets.description': ['*.rst'],\n                         'nilearn.reporting.data.html': ['*.html']},\n-          install_requires=install_requires,)\n+          install_requires=install_requires,\n+          python_requires='>=3.5',\n+          )\n", "issue": "Pip installing Nilearn 0.6.0a0 in Py2 envs\nNot sure why, installing Nilearn 06.0a0 in a Python2environment does not raise an error. This is strange, since the wheels I build this time are not universal and I removed Python 2 tags. Maybe something was overlooked? Will look at this.\n", "before_files": [{"content": "#! /usr/bin/env python\n\ndescr = \"\"\"A set of python modules for neuroimaging...\"\"\"\n\nimport sys\nimport os\n\nfrom setuptools import setup, find_packages\n\n\ndef load_version():\n    \"\"\"Executes nilearn/version.py in a globals dictionary and return it.\n\n    Note: importing nilearn is not an option because there may be\n    dependencies like nibabel which are not installed and\n    setup.py is supposed to install them.\n    \"\"\"\n    # load all vars into globals, otherwise\n    #   the later function call using global vars doesn't work.\n    globals_dict = {}\n    with open(os.path.join('nilearn', 'version.py')) as fp:\n        exec(fp.read(), globals_dict)\n\n    return globals_dict\n\n\ndef is_installing():\n    # Allow command-lines such as \"python setup.py build install\"\n    install_commands = set(['install', 'develop'])\n    return install_commands.intersection(set(sys.argv))\n\n\n# Make sources available using relative paths from this file's directory.\nos.chdir(os.path.dirname(os.path.abspath(__file__)))\n\n_VERSION_GLOBALS = load_version()\nDISTNAME = 'nilearn'\nDESCRIPTION = 'Statistical learning for neuroimaging in Python'\nwith open('README.rst') as fp:\n    LONG_DESCRIPTION = fp.read()\nMAINTAINER = 'Gael Varoquaux'\nMAINTAINER_EMAIL = 'gael.varoquaux@normalesup.org'\nURL = 'http://nilearn.github.io'\nLICENSE = 'new BSD'\nDOWNLOAD_URL = 'http://nilearn.github.io'\nVERSION = _VERSION_GLOBALS['__version__']\n\n\nif __name__ == \"__main__\":\n    if is_installing():\n        module_check_fn = _VERSION_GLOBALS['_check_module_dependencies']\n        module_check_fn(is_nilearn_installing=True)\n\n    install_requires = \\\n        ['%s>=%s' % (mod, meta['min_version'])\n            for mod, meta in _VERSION_GLOBALS['REQUIRED_MODULE_METADATA']\n            if not meta['required_at_installation']]\n\n    setup(name=DISTNAME,\n          maintainer=MAINTAINER,\n          maintainer_email=MAINTAINER_EMAIL,\n          description=DESCRIPTION,\n          license=LICENSE,\n          url=URL,\n          version=VERSION,\n          download_url=DOWNLOAD_URL,\n          long_description=LONG_DESCRIPTION,\n          zip_safe=False,  # the package can run out of an .egg file\n          classifiers=[\n              'Intended Audience :: Science/Research',\n              'Intended Audience :: Developers',\n              'License :: OSI Approved',\n              'Programming Language :: C',\n              'Programming Language :: Python',\n              'Topic :: Software Development',\n              'Topic :: Scientific/Engineering',\n              'Operating System :: Microsoft :: Windows',\n              'Operating System :: POSIX',\n              'Operating System :: Unix',\n              'Operating System :: MacOS',\n              'Programming Language :: Python :: 3.5',\n              'Programming Language :: Python :: 3.6',\n              'Programming Language :: Python :: 3.7',\n          ],\n          packages=find_packages(),\n          package_data={'nilearn.datasets.data': ['*.nii.gz', '*.csv', '*.txt'\n                                                  ],\n                        'nilearn.datasets.data.fsaverage5': ['*.gz'],\n                        'nilearn.surface.data': ['*.csv'],\n                        'nilearn.plotting.data.js': ['*.js'],\n                        'nilearn.plotting.data.html': ['*.html'],\n                        'nilearn.plotting.glass_brain_files': ['*.json'],\n                        'nilearn.tests.data': ['*'],\n                        'nilearn.image.tests.data': ['*.mgz'],\n                        'nilearn.surface.tests.data': ['*.annot', '*.label'],\n                        'nilearn.datasets.tests.data': ['*.*'],\n                        'nilearn.datasets.description': ['*.rst'],\n                        'nilearn.reporting.data.html': ['*.html']},\n          install_requires=install_requires,)\n", "path": "setup.py"}, {"content": "# *- encoding: utf-8 -*-\n\"\"\"\nnilearn version, required package versions, and utilities for checking\n\"\"\"\n# Author: Loic Esteve, Ben Cipollini\n# License: simplified BSD\n\n# PEP0440 compatible formatted version, see:\n# https://www.python.org/dev/peps/pep-0440/\n#\n# Generic release markers:\n# X.Y\n# X.Y.Z # For bugfix releases\n#\n# Admissible pre-release markers:\n# X.YaN # Alpha release\n# X.YbN # Beta release\n# X.YrcN # Release Candidate\n# X.Y # Final release\n#\n# Dev branch marker is: 'X.Y.dev' or 'X.Y.devN' where N is an integer.\n# 'X.Y.dev0' is the canonical version of 'X.Y.dev'\n#\n__version__ = '0.6.0a'\n\n_NILEARN_INSTALL_MSG = 'See %s for installation information.' % (\n    'http://nilearn.github.io/introduction.html#installation')\n\n# This is a tuple to preserve order, so that dependencies are checked\n#   in some meaningful order (more => less 'core').\nREQUIRED_MODULE_METADATA = (\n    ('numpy', {\n        'min_version': '1.11',\n        'required_at_installation': True,\n        'install_info': _NILEARN_INSTALL_MSG}),\n    ('scipy', {\n        'min_version': '0.19',\n        'required_at_installation': True,\n        'install_info': _NILEARN_INSTALL_MSG}),\n    ('sklearn', {\n        'min_version': '0.19',\n        'required_at_installation': True,\n        'install_info': _NILEARN_INSTALL_MSG}),\n    ('joblib', {\n        'min_version': '0.11',\n        'required_at_installation': True,\n        'install_info': _NILEARN_INSTALL_MSG}),\n    ('nibabel', {\n        'min_version': '2.0.2',\n        'required_at_installation': False}))\n\nOPTIONAL_MATPLOTLIB_MIN_VERSION = '2.0'\n\n\ndef _import_module_with_version_check(\n        module_name,\n        minimum_version,\n        install_info=None):\n    \"\"\"Check that module is installed with a recent enough version\n    \"\"\"\n    from distutils.version import LooseVersion\n\n    try:\n        module = __import__(module_name)\n    except ImportError as exc:\n        user_friendly_info = ('Module \"{0}\" could not be found. {1}').format(\n            module_name,\n            install_info or 'Please install it properly to use nilearn.')\n        exc.args += (user_friendly_info,)\n        # Necessary for Python 3 because the repr/str of ImportError\n        # objects was changed in Python 3\n        if hasattr(exc, 'msg'):\n            exc.msg += '. ' + user_friendly_info\n        raise\n\n    # Avoid choking on modules with no __version__ attribute\n    module_version = getattr(module, '__version__', '0.0.0')\n\n    version_too_old = (not LooseVersion(module_version) >=\n                       LooseVersion(minimum_version))\n\n    if version_too_old:\n        message = (\n            'A {module_name} version of at least {minimum_version} '\n            'is required to use nilearn. {module_version} was found. '\n            'Please upgrade {module_name}').format(\n                module_name=module_name,\n                minimum_version=minimum_version,\n                module_version=module_version)\n\n        raise ImportError(message)\n\n    return module\n\n\ndef _check_module_dependencies(is_nilearn_installing=False):\n    \"\"\"Throw an exception if nilearn dependencies are not installed.\n\n    Parameters\n    ----------\n    is_nilearn_installing: boolean\n        if True, only error on missing packages that cannot be auto-installed.\n        if False, error on any missing package.\n\n    Throws\n    -------\n    ImportError\n    \"\"\"\n\n    for (module_name, module_metadata) in REQUIRED_MODULE_METADATA:\n        if not (is_nilearn_installing and\n                not module_metadata['required_at_installation']):\n            # Skip check only when installing and it's a module that\n            # will be auto-installed.\n            _import_module_with_version_check(\n                module_name=module_name,\n                minimum_version=module_metadata['min_version'],\n                install_info=module_metadata.get('install_info'))\n", "path": "nilearn/version.py"}], "after_files": [{"content": "#! /usr/bin/env python\n\ndescr = \"\"\"A set of python modules for neuroimaging...\"\"\"\n\nimport sys\nimport os\n\nfrom setuptools import setup, find_packages\n\n\ndef load_version():\n    \"\"\"Executes nilearn/version.py in a globals dictionary and return it.\n\n    Note: importing nilearn is not an option because there may be\n    dependencies like nibabel which are not installed and\n    setup.py is supposed to install them.\n    \"\"\"\n    # load all vars into globals, otherwise\n    #   the later function call using global vars doesn't work.\n    globals_dict = {}\n    with open(os.path.join('nilearn', 'version.py')) as fp:\n        exec(fp.read(), globals_dict)\n\n    return globals_dict\n\n\ndef is_installing():\n    # Allow command-lines such as \"python setup.py build install\"\n    install_commands = set(['install', 'develop'])\n    return install_commands.intersection(set(sys.argv))\n\n\n# Make sources available using relative paths from this file's directory.\nos.chdir(os.path.dirname(os.path.abspath(__file__)))\n\n_VERSION_GLOBALS = load_version()\nDISTNAME = 'nilearn'\nDESCRIPTION = 'Statistical learning for neuroimaging in Python'\nwith open('README.rst') as fp:\n    LONG_DESCRIPTION = fp.read()\nMAINTAINER = 'Gael Varoquaux'\nMAINTAINER_EMAIL = 'gael.varoquaux@normalesup.org'\nURL = 'http://nilearn.github.io'\nLICENSE = 'new BSD'\nDOWNLOAD_URL = 'http://nilearn.github.io'\nVERSION = _VERSION_GLOBALS['__version__']\n\n\nif __name__ == \"__main__\":\n    if is_installing():\n        module_check_fn = _VERSION_GLOBALS['_check_module_dependencies']\n        module_check_fn(is_nilearn_installing=True)\n\n    install_requires = \\\n        ['%s>=%s' % (mod, meta['min_version'])\n            for mod, meta in _VERSION_GLOBALS['REQUIRED_MODULE_METADATA']\n            if not meta['required_at_installation']]\n\n    setup(name=DISTNAME,\n          maintainer=MAINTAINER,\n          maintainer_email=MAINTAINER_EMAIL,\n          description=DESCRIPTION,\n          license=LICENSE,\n          url=URL,\n          version=VERSION,\n          download_url=DOWNLOAD_URL,\n          long_description=LONG_DESCRIPTION,\n          zip_safe=False,  # the package can run out of an .egg file\n          classifiers=[\n              'Intended Audience :: Science/Research',\n              'Intended Audience :: Developers',\n              'License :: OSI Approved',\n              'Programming Language :: C',\n              'Programming Language :: Python',\n              'Topic :: Software Development',\n              'Topic :: Scientific/Engineering',\n              'Operating System :: Microsoft :: Windows',\n              'Operating System :: POSIX',\n              'Operating System :: Unix',\n              'Operating System :: MacOS',\n              'Programming Language :: Python :: 3.5',\n              'Programming Language :: Python :: 3.6',\n              'Programming Language :: Python :: 3.7',\n          ],\n          packages=find_packages(),\n          package_data={'nilearn.datasets.data': ['*.nii.gz', '*.csv', '*.txt'\n                                                  ],\n                        'nilearn.datasets.data.fsaverage5': ['*.gz'],\n                        'nilearn.surface.data': ['*.csv'],\n                        'nilearn.plotting.data.js': ['*.js'],\n                        'nilearn.plotting.data.html': ['*.html'],\n                        'nilearn.plotting.glass_brain_files': ['*.json'],\n                        'nilearn.tests.data': ['*'],\n                        'nilearn.image.tests.data': ['*.mgz'],\n                        'nilearn.surface.tests.data': ['*.annot', '*.label'],\n                        'nilearn.datasets.tests.data': ['*.*'],\n                        'nilearn.datasets.description': ['*.rst'],\n                        'nilearn.reporting.data.html': ['*.html']},\n          install_requires=install_requires,\n          python_requires='>=3.5',\n          )\n", "path": "setup.py"}, {"content": "# *- encoding: utf-8 -*-\n\"\"\"\nnilearn version, required package versions, and utilities for checking\n\"\"\"\n# Author: Loic Esteve, Ben Cipollini\n# License: simplified BSD\n\n# PEP0440 compatible formatted version, see:\n# https://www.python.org/dev/peps/pep-0440/\n#\n# Generic release markers:\n# X.Y\n# X.Y.Z # For bugfix releases\n#\n# Admissible pre-release markers:\n# X.YaN # Alpha release\n# X.YbN # Beta release\n# X.YrcN # Release Candidate\n# X.Y # Final release\n#\n# Dev branch marker is: 'X.Y.dev' or 'X.Y.devN' where N is an integer.\n# 'X.Y.dev0' is the canonical version of 'X.Y.dev'\n#\n__version__ = '0.6.0b'\n\n_NILEARN_INSTALL_MSG = 'See %s for installation information.' % (\n    'http://nilearn.github.io/introduction.html#installation')\n\n# This is a tuple to preserve order, so that dependencies are checked\n#   in some meaningful order (more => less 'core').\nREQUIRED_MODULE_METADATA = (\n    ('numpy', {\n        'min_version': '1.11',\n        'required_at_installation': True,\n        'install_info': _NILEARN_INSTALL_MSG}),\n    ('scipy', {\n        'min_version': '0.19',\n        'required_at_installation': True,\n        'install_info': _NILEARN_INSTALL_MSG}),\n    ('sklearn', {\n        'min_version': '0.19',\n        'required_at_installation': True,\n        'install_info': _NILEARN_INSTALL_MSG}),\n    ('joblib', {\n        'min_version': '0.11',\n        'required_at_installation': True,\n        'install_info': _NILEARN_INSTALL_MSG}),\n    ('nibabel', {\n        'min_version': '2.0.2',\n        'required_at_installation': False}))\n\nOPTIONAL_MATPLOTLIB_MIN_VERSION = '2.0'\n\n\ndef _import_module_with_version_check(\n        module_name,\n        minimum_version,\n        install_info=None):\n    \"\"\"Check that module is installed with a recent enough version\n    \"\"\"\n    from distutils.version import LooseVersion\n\n    try:\n        module = __import__(module_name)\n    except ImportError as exc:\n        user_friendly_info = ('Module \"{0}\" could not be found. {1}').format(\n            module_name,\n            install_info or 'Please install it properly to use nilearn.')\n        exc.args += (user_friendly_info,)\n        # Necessary for Python 3 because the repr/str of ImportError\n        # objects was changed in Python 3\n        if hasattr(exc, 'msg'):\n            exc.msg += '. ' + user_friendly_info\n        raise\n\n    # Avoid choking on modules with no __version__ attribute\n    module_version = getattr(module, '__version__', '0.0.0')\n\n    version_too_old = (not LooseVersion(module_version) >=\n                       LooseVersion(minimum_version))\n\n    if version_too_old:\n        message = (\n            'A {module_name} version of at least {minimum_version} '\n            'is required to use nilearn. {module_version} was found. '\n            'Please upgrade {module_name}').format(\n                module_name=module_name,\n                minimum_version=minimum_version,\n                module_version=module_version)\n\n        raise ImportError(message)\n\n    return module\n\n\ndef _check_module_dependencies(is_nilearn_installing=False):\n    \"\"\"Throw an exception if nilearn dependencies are not installed.\n\n    Parameters\n    ----------\n    is_nilearn_installing: boolean\n        if True, only error on missing packages that cannot be auto-installed.\n        if False, error on any missing package.\n\n    Throws\n    -------\n    ImportError\n    \"\"\"\n\n    for (module_name, module_metadata) in REQUIRED_MODULE_METADATA:\n        if not (is_nilearn_installing and\n                not module_metadata['required_at_installation']):\n            # Skip check only when installing and it's a module that\n            # will be auto-installed.\n            _import_module_with_version_check(\n                module_name=module_name,\n                minimum_version=module_metadata['min_version'],\n                install_info=module_metadata.get('install_info'))\n", "path": "nilearn/version.py"}]}