Skip to content

Commit 76fc838

Browse files
authored
backport new environment file and install instructions (#7979)
* only update install instructions * add nitpick ignore * another nitpick
1 parent cb8a99e commit 76fc838

File tree

4 files changed

+176
-56
lines changed

4 files changed

+176
-56
lines changed

doc/conf.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,16 @@
110110
td.isoformat())
111111

112112
nitpicky = True
113+
nitpick_ignore = [
114+
("py:class", "None. Remove all items from D."),
115+
("py:class", "a set-like object providing a view on D's items"),
116+
("py:class", "a set-like object providing a view on D's keys"),
117+
("py:class", "v, remove specified key and return the corresponding value."), # noqa: E501
118+
("py:class", "None. Update D from dict/iterable E and F."),
119+
("py:class", "an object providing a view on D's values"),
120+
("py:class", "a shallow copy of D"),
121+
("py:class", "(k, v), remove and return some (key, value) pair as a"),
122+
]
113123
suppress_warnings = ['image.nonlocal_uri'] # we intentionally link outside
114124

115125
# The version info for the project you're documenting, acts as replacement for

doc/install/advanced.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,13 @@ interactivity within the scene is limited in non-blocking plot calls.
5757
In [1]: from mayavi import mlab
5858
In [2]: %gui qt
5959
60+
If you installed the ``nb_conda_kernels`` package into your ``base``
61+
environment (as recommended), you should be able to launch ``mne``-capable
62+
notebooks from within the Anaconda Navigator GUI without having to explicitly
63+
switch to the ``mne`` environment first; look for ``Python [conda env:mne]``
64+
when choosing which notebook kernel to use. Otherwise, be sure to activate the
65+
``mne`` environment before launching the notebook.
66+
6067
If you use another Python setup and you encounter some difficulties please
6168
report them on the `MNE mailing list`_ or on the `GitHub issues page`_ to get
6269
assistance.

doc/install/mne_python.rst

Lines changed: 158 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ To get started, follow the `installation instructions for Anaconda`_.
3636
(indeed, preferable) to leave ``PYTHONPATH`` and ``PYTHONHOME`` permanently
3737
unset.
3838

39-
When you are done, if you type the following commands in a ``bash`` terminal,
39+
When you are done, if you type the following commands in a command shell,
4040
you should see outputs similar to the following (assuming you installed
4141
conda to ``/home/user/anaconda3``)::
4242

@@ -54,14 +54,16 @@ conda to ``/home/user/anaconda3``)::
5454
.. rubric:: If you are on a |windows| Windows command prompt:
5555

5656
Most of our instructions start with ``$``, which indicates
57-
that the commands are designed to be run from a Bash command prompt.
57+
that the commands are designed to be run from a ``bash`` command shell.
5858

59-
Windows command prompts do not expose the same command-line tools as Bash
60-
shells, so things like ``which`` will not work, and you need to use
61-
alternatives, such as::
59+
Windows command prompts do not expose the same command-line tools as
60+
``bash`` shells, so commands like ``which`` will not work. You can test
61+
your installation in Windows ``cmd.exe`` shells with ``where`` instead::
6262

63-
> where mne
64-
C:\Users\mneuser\Anaconda3\Scripts\mne
63+
> where python
64+
C:\Users\user\anaconda3\python.exe
65+
> where pip
66+
C:\Users\user\anaconda3\Scripts\pip.exe
6567

6668
.. rubric:: If you see something like:
6769

@@ -79,13 +81,18 @@ conda to ``/home/user/anaconda3``)::
7981
(probably at or near the beginning), but the ``command not found`` error
8082
suggests that it is missing.
8183

82-
On Linux or OSX, the installer should have put something
83-
like the following in your ``~/.bashrc`` or ``~/.bash_profile``
84-
(or somewhere else if you are using a non-bash terminal):
84+
On Linux or macOS, the installer should have put something
85+
like the following in your ``~/.bashrc`` or ``~/.bash_profile`` (or your
86+
``.zprofile`` if you're using macOS Catalina or later, where the default
87+
shell is ``zsh``):
8588

8689
.. code-block:: bash
8790
88-
. ~/anaconda3/etc/profile.d/conda.sh
91+
# >>> conda initialize >>>
92+
# !! Contents within this block are managed by 'conda init' !!
93+
__conda_setup= ...
94+
...
95+
# <<< conda initialize <<<
8996
9097
If this is missing, it is possible that you are not on the same shell that
9198
was used during the installation. You can verify which shell you are on by
@@ -94,22 +101,14 @@ conda to ``/home/user/anaconda3``)::
94101
$ echo $SHELL
95102

96103
If you do not find this line in the configuration file for the shell you
97-
are using (bash, tcsh, etc.), add the line to that shell's ``rc`` or
98-
``profile`` file to fix the problem.
104+
are using (bash, zsh, tcsh, etc.), try running::
99105

100-
.. rubric:: If you see an error like:
101-
102-
::
103-
104-
CommandNotFoundError: Your shell has not been properly configured to use 'conda activate'.
105-
106-
It means that you have used an old method to set up Anaconda. This
107-
means that you have something like::
106+
conda init
108107

109-
PATH=~/anaconda3/bin:$PATH
110-
111-
in your ``~/.bash_profile``. You should update this line to use
112-
the modern way using ``anaconda3/etc/profile.d/conda.sh`` above.
108+
in your command shell. If your shell is not ``cmd.exe`` (Windows) or
109+
``bash`` (Linux, macOS) you will need to pass the name of the shell to the
110+
``conda init`` command. See ``conda init --help`` for more info and
111+
supported shells.
113112

114113
You can also consult the Anaconda documentation and search for
115114
Anaconda install tips (`Stack Overflow`_ results are often helpful)
@@ -120,29 +119,61 @@ conda to ``/home/user/anaconda3``)::
120119
Installing MNE-Python and its dependencies
121120
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
122121

123-
Once you have Anaconda installed, the easiest way to install
124-
MNE-Python with all dependencies is update your base Anaconda environment:
122+
Once you have Python/Anaconda installed, you have a few choices for how to
123+
install MNE-Python.
125124

126-
.. _environment file: https://raw.githubusercontent.com/mne-tools/mne-python/master/environment.yml
125+
For sensor-level analysis
126+
~~~~~~~~~~~~~~~~~~~~~~~~~
127+
128+
If you only need 2D plotting capabilities with MNE-Python (i.e., most EEG/ERP
129+
or other sensor-level analyses), you can install all you need by running
130+
``pip install mne`` in a terminal window (on Windows, use the "Anaconda Prompt"
131+
from the Start menu, or the "CMD.exe prompt" from within the Anaconda Navigator
132+
GUI). This will install MNE-Python into the "base" conda environment, which
133+
should be active by default and should already have the necessary dependencies
134+
(``numpy``, ``scipy``, and ``matplotlib``).
135+
136+
For 3D plotting and source analysis
137+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
138+
139+
If you need MNE-Python's 3D plotting capabilities (e.g., plotting estimated
140+
source activity on a cortical surface) it is a good idea to install
141+
MNE-Python into its own virtual environment, so that the extra dependencies
142+
needed for 3D plotting stay in sync (i.e., they only get updated to versions
143+
that are compatible with MNE-Python). See the detailed instructions below for
144+
your operating system.
127145

128146
.. collapse:: |linux| Linux
129147

130-
Use the base `environment file`_, e.g.::
148+
Download the MNE-Python `environment file`_ (done here with ``curl``) and
149+
use it to create a new environment (named ``mne`` by default)::
131150

132151
$ curl --remote-name https://raw.githubusercontent.com/mne-tools/mne-python/master/environment.yml
133152
$ conda env update --file environment.yml
134153

154+
.. collapse:: |hand-stop-o| If you get errors building mayavi...
155+
:class: danger
156+
157+
Installing `mayavi`_ needs OpenGL support. On debian-like systems this
158+
means installing ``libopengl0``, i.e., ``sudo apt install libopengl0``.
159+
135160
.. collapse:: |apple| macOS
136161

137-
Use the base `environment file`_, e.g.::
162+
Update the ``base`` conda environment to include the ``nb_conda_kernels``
163+
package, so you can use MNE-Python in Jupyter Notebooks launched from the
164+
Anaconda GUI. Then download the MNE-Python `environment file`_ (done here
165+
with ``curl``) and use it to create a new environment (named ``mne`` by
166+
default)::
138167

168+
$ conda install --name base nb_conda_kernels
139169
$ curl --remote-name https://raw.githubusercontent.com/mne-tools/mne-python/master/environment.yml
140170
$ conda env update --file environment.yml
141171

142172
.. collapse:: |windows| Windows
143173

144-
- Download the base `environment file`_
174+
- Download the `environment file`_
145175
- Open an Anaconda command prompt
176+
- Run :samp:`conda install --name base nb_conda_kernels`
146177
- :samp:`cd` to the directory where you downloaded the file
147178
- Run :samp:`conda env update --file environment.yml`
148179

@@ -170,9 +201,17 @@ you can create a new dedicated environment (here called "mne") with
170201
});
171202
</script>
172203

173-
.. collapse:: |hand-stop-o| If you are installing on a headless server...
204+
Installing to a headless server
205+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
206+
207+
.. collapse:: |server| If you are installing on a headless server...
174208
:class: danger
175209

210+
With `pyvista`_:
211+
Follow the steps described in :ref:`standard_instructions`
212+
but use the `server environment file`_ instead of the `environment file`_.
213+
214+
With `mayavi`_:
176215
Installing `mayavi`_ requires a running `X server`_. If you are
177216
installing MNE-Python into a computer with no display connected to it, you
178217
can try removing `mayavi`_ from the :file:`environment.yml` file before
@@ -191,31 +230,33 @@ Testing MNE-Python installation
191230
To make sure MNE-Python installed itself and its dependencies correctly,
192231
type the following command in a terminal::
193232

194-
$ mne sys_info
233+
$ python -c "import mne; mne.sys_info()"
195234

196235
This should display some system information along with the versions of
197236
MNE-Python and its dependencies. Typical output looks like this::
198237

199-
Platform: Linux-4.18.0-13-generic-x86_64-with-debian-buster-sid
200-
Python: 3.6.8 |Anaconda, Inc.| (default, Dec 30 2018, 01:22:34) [GCC 7.3.0]
201-
Executable: /home/travis/miniconda/bin/python
202-
CPU: x86_64: 48 cores
203-
Memory: 62.7 GB
238+
Platform: Linux-5.0.0-1031-gcp-x86_64-with-glibc2.2.5
239+
Python: 3.8.1 (default, Dec 20 2019, 10:06:11) [GCC 7.4.0]
240+
Executable: /home/travis/virtualenv/python3.8.1/bin/python
241+
CPU: x86_64: 2 cores
242+
Memory: 7.8 GB
204243

205-
mne: 0.17.0
206-
numpy: 1.15.4 {blas=mkl_rt, lapack=mkl_rt}
207-
scipy: 1.2.0
208-
matplotlib: 3.0.2 {backend=Qt5Agg}
244+
mne: 0.21.dev0
245+
numpy: 1.19.0.dev0+8dfaa4a {blas=openblas, lapack=openblas}
246+
scipy: 1.5.0.dev0+f614064
247+
matplotlib: 3.2.1 {backend=Qt5Agg}
209248

210-
sklearn: 0.20.2
211-
numba: 0.45.0
212-
nibabel: 2.3.3
249+
sklearn: 0.22.2.post1
250+
numba: 0.49.0
251+
nibabel: 3.1.0
213252
cupy: Not found
214-
pandas: 0.24.0
215-
dipy: 0.15.0
216-
mayavi: 4.7.1 {qt_api=pyqt5, PyQt5=5.10.1}
217-
pyvista: 0.21.3
218-
vtk: 8.2.0
253+
pandas: 1.0.3
254+
dipy: 1.1.1
255+
mayavi: 4.7.2.dev0
256+
pyvista: 0.25.2 {pyvistaqt=0.1.0}
257+
vtk: 9.0.0
258+
PyQt5: 5.14.1
259+
219260

220261
.. collapse:: |hand-stop-o| If you get an error...
221262
:class: danger
@@ -228,26 +269,88 @@ MNE-Python and its dependencies. Typical output looks like this::
228269
File "<string>", line 1, in <module>
229270
ModuleNotFoundError: No module named 'mne'
230271

231-
This suggests that your environment containing ``mne`` is not active.
232-
If you installed to the ``mne`` instead of ``base`` environment, try doing
233-
``conda activate mne`` and try again. If this works, you might want to
234-
add ``conda activate mne`` to the end of your ``~/.bashrc`` or
235-
``~/.bash_profile`` files so that it gets executed automatically.
272+
This suggests that your environment containing MNE-Python is not active.
273+
If you followed the setup for 3D plotting/source analysis (i.e., you
274+
installed to a new ``mne`` environment instead of the ``base`` environment)
275+
try running ``conda activate mne`` first, and try again. If this works,
276+
you might want to set your terminal to automatically activate the
277+
``mne`` environment each time you open a terminal::
278+
279+
$ echo conda activate mne >> ~/.bashrc # for bash shells
280+
$ echo conda activate mne >> ~/.zprofile # for zsh shells
236281

237282
If something else went wrong during installation and you can't figure it out,
238283
check out the :doc:`advanced` page to see if your problem is discussed there.
239284
If not, the `MNE mailing list`_ and `MNE gitter channel`_ are
240285
good resources for troubleshooting installation problems.
241286

287+
288+
Installing a Python IDE
289+
^^^^^^^^^^^^^^^^^^^^^^^
290+
291+
Most users find it convenient to write and run their code in an `Integrated
292+
Development Environment`_ (IDE). Some popular choices for scientific
293+
Python development are:
294+
295+
- `Spyder`_ is a free and open-source IDE developed by and for scientists who
296+
use Python. It is included by default in the ``base`` environment when you
297+
install Anaconda, and can be started from a terminal with the command
298+
``spyder`` (or on Windows or macOS, launched from the Anaconda Navigator GUI).
299+
If you installed MNE-Python into a separate ``mne`` environment (not the
300+
``base`` Anaconda environment), you can set up Spyder to use the ``mne``
301+
environment automatically, by opening Spyder and navigating to
302+
:samp:`Tools > Preferences > Python Interpreter > Use the following interpreter`.
303+
There, paste the output of the following terminal command::
304+
305+
$ conda activate mne && python -c "import sys; print(sys.executable)"
306+
307+
It should be something like ``C:\Users\user\anaconda3\envs\mne\python.exe``
308+
(Windows) or ``/Users/user/anaconda3/envs/mne/bin/python`` (macOS).
309+
- `Visual Studio Code`_ (often shortened to "VS Code" or "vscode") is a
310+
development-focused text editor that supports many programming languages in
311+
addition to Python, includes an integrated terminal console, and has a rich
312+
ecosystem of packages to extend its capabilities. Installing
313+
`Microsoft's Python Extension
314+
<https://marketplace.visualstudio.com/items?itemName=ms-python.python>`__ is
315+
enough to get most Python users up and running. VS Code is free and
316+
open-source.
317+
- `Atom`_ is a text editor similar to vscode, with a package ecosystem that
318+
includes a `Python IDE package <https://atom.io/packages/ide-python>`__ as
319+
well as `several <https://atom.io/packages/atom-terminal>`__
320+
`packages <https://atom.io/packages/atom-terminal-panel>`__
321+
`for <https://atom.io/packages/terminal-plus>`__
322+
`integrated <https://atom.io/packages/platformio-ide-terminal>`__
323+
`terminals <https://atom.io/packages/term3>`__. Atom is free and open-source.
324+
- `SublimeText`_ is a general-purpose text editor that is fast and lightweight,
325+
and also has a rich package ecosystem. There is a package called `Terminus`_
326+
that provides an integrated terminal console, and a (confusingly named)
327+
package called "anaconda"
328+
(`found here <https://packagecontrol.io/packages/Anaconda>`__) that provides
329+
many Python-specific features. SublimeText is free (closed-source shareware).
330+
- `PyCharm`_ is an IDE specifically for Python development that provides an
331+
all-in-one installation (no extension packages needed). PyCharm comes in a
332+
free "community" edition and a paid "professional" edition, and is
333+
closed-source.
334+
242335
.. highlight:: python
243336

244337
**Next:** :doc:`freesurfer`
245338

246339

247340
.. LINKS
248341
342+
.. _environment file: https://raw.githubusercontent.com/mne-tools/mne-python/master/environment.yml
343+
.. _server environment file: https://raw.githubusercontent.com/mne-tools/mne-python/master/server_environment.yml
249344
.. _`mayavi`: https://docs.enthought.com/mayavi/mayavi/
345+
.. _`pyvista`: https://docs.pyvista.org/
250346
.. _`X server`: https://en.wikipedia.org/wiki/X_Window_System
251347
.. _`xvfb`: https://en.wikipedia.org/wiki/Xvfb
252348
.. _`off-screen rendering`: https://docs.enthought.com/mayavi/mayavi/tips.html#off-screen-rendering
253349
.. _`rendering with a virtual framebuffer`: https://docs.enthought.com/mayavi/mayavi/tips.html#rendering-using-the-virtual-framebuffer
350+
.. _`integrated development environment`: https://en.wikipedia.org/wiki/Integrated_development_environment
351+
.. _`spyder`: https://www.spyder-ide.org/
352+
.. _`visual studio code`: https://code.visualstudio.com/
353+
.. _`sublimetext`: https://www.sublimetext.com/
354+
.. _`terminus`: https://packagecontrol.io/packages/Terminus
355+
.. _`pycharm`: https://www.jetbrains.com/pycharm/
356+
.. _`atom`: https://atom.io/

doc/install/pre_install.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ Overview of the MNE tools suite
1818

1919
- :doc:`MNE-Python <../python_reference>` reimplements the functionality of
2020
MNE-C, and extends considerably the analysis and visualization capabilities.
21-
MNE-Python is collaboratively developed and has more than 150 contributors.
21+
MNE-Python is collaboratively developed and has more than 200 contributors.
2222

2323
- The :ref:`mne_matlab` provides a MATLAB interface to the .fif file
2424
format and other MNE data structures, and provides example MATLAB

0 commit comments

Comments
 (0)