If you are same as me, you probably love to work with Python because of it’s versatility and open-source. Since I was participated on some Python projects I started to do more in Python than in MATLAB as I did before. But I like clean solutions.
There are tons of tutorials how to install Python2/3 on macOS, how to install Anaconda and Spyder etc. I found the Spyder IDE as best to fit my needs. It is very similar to MATLAB so you won’t loose your learned skills as it is decribed here.
When you run Spyder and try to import some unusuall liberary you should get error that there is no module named like that. For importing
mne module i got this out-of-the-box.
Traceback (most recent call last): File "<ipython-input-3-4964879682bf>", line 1, in <module> <span style="font-family: 'Noto Serif', Georgia, 'Times New Roman', Times, serif; background-color: #ffffff;">import mne </span>ImportError: No module named 'mne'
So we need to download our library. One way (it is not described in here) is to download a ZIP file from Github or the library page at store them somewhere on your drive. Or download Python 3.6 on Python website.
After you install Python 3.6. Open terminal and enter
which python3, you should end up with something like this
. This means that Python 3.6 is successfully instaleld on your drive. Then you can use a regular way to install packages via pip.
After installing the mne module by entering `pip3 install mne` in terminal I have installed my module in my Python distribution. I need to know where the Python3 stores a so called site-packages (library of packages). I can be done very easily by
import mne mne
It returns something like this:
python <module 'mne' from '/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/mne/__init__.py'>
So this is our desired location where python stores all liberaries.
After that open Spyder settings > iPython console > startup tab > and start to write in Lines collumn.
import sys, sys.path.append(“/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages”)
Of course you have to enter your path to append your site-package at the start.