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.

First it will only work for Python 3.5 so if you need for some dependecy reasons use Python 2.7.x or Python 3.x.x this tutorial is not going to work. Download Spyder from Github releases page.

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

/Library/Frameworks/Python.framework/Versions/3.6/bin/python3

. 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.

Snímek obrazovky 2017-05-17 v 21.50.56.png

After that open Spyder settings > iPython console > startup tab > and start to write in Lines collumn.

“`python

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.

Snímek obrazovky 2017-05-17 v 21.54.04.png

Advertisements

One thought on “Spyder IDE, macOS and installing modules…

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s