Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Errors using Python with MATLAB #19

Open
nishiyor opened this issue Jun 12, 2020 · 1 comment
Open

Errors using Python with MATLAB #19

nishiyor opened this issue Jun 12, 2020 · 1 comment

Comments

@nishiyor
Copy link

I am new to using Python in MATLAB, but would like to use fooof to analyze EEG data. I am using a Mac (Mojave 10.14.16) with MATLAB 2019a. As much as I would like to update both or either of these, this is a lab computer, so I have very little control over it.

I followed the steps here to install the most recent version of Python (v 3.8). I ran into the error addressed in the issue regarding missing 'py' variable. I ran the 'install numpy', but still get the same error (missing 'py'). I notice that in MATLAB, after running 'pyversion', it says I am using version 2.7. When I run IDLE, it says my version is 3.8.3. The library and home paths all indicate that the version of Python I am using is 2.7. Assuming that this is the issue that is preventing me from using fooof, how can I correct this?

Thank you for your time in advance.

@TomDonoghue
Copy link
Member

TomDonoghue commented Jul 9, 2020

Hey @nishiyor - sorry for the delay in getting back to you!

If Matlab is showing you that it sees Python 2.7, then this is the issue. It means Matlab isn't seeing the correct Python. This won't work for using FOOOF, as FOOOF requires requires Python 3 (and some dependencies), which means you need to get Matlab to call the Python 3.8 version you have.

Have you tried the notes in the README about updating which Python Matlab is calling:
https://github.com/fooof-tools/fooof_mat#calling-python-from-matlab
^Note that to do this approach, you might need to check where your Python 3.8 version lives, and make sure to use that specific path to update to.

Another user recently wrote a blog post about setting Matlab up to call Python, that may be helpful:
https://irenevigueguix.wordpress.com/2020/03/25/loading-python-into-matlab/

If neither of those things work, let us know - but I'm not 100% sure what else to do. Note that this isn't a FOOOF problem, it's something to do with Matlab, on which I'm not an expert. You might need to look into Matlab stuff for how it calls Python. For newer version of Matlab, you might want to look into and try out pyenv:
https://www.mathworks.com/help/matlab/ref/pyenv.html

Note that if you have Python 3.8 up and running, with IDLE, one option is to do your FOOOF fitting directly in Python. This can still be integrated into a Matlab based workflow. Some discussion about and examples of this are available here:
https://github.com/fooof-tools/mat_py_mat

Hope that help! If you are still having trouble, let us know know, and we can try and trouble-shoot some more.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants