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

Undefined variable "py" or class "py.numpy.array" when running MATLAB wrapper #12

Open
NeilwBailey opened this issue Oct 16, 2018 · 5 comments

Comments

@NeilwBailey
Copy link

When I try to run the MATLAB error, I get the following error, even though all the dependencies are installed and pyversion is correctly specified in MATLAB:

example_wrapper_multi_psd
Undefined variable "py" or class "py.numpy.array".

Error in fooof (line 37)
freqs = py.numpy.array(freqs);

Error in fooof_group (line 41)
cur_results = fooof(freqs, psd', f_range, settings);

Error in example_wrapper_multi_psd (line 21)
fooof_results = fooof_group(freqs, psds, f_range, settings);

@stahn76
Copy link

stahn76 commented Mar 5, 2019

I installed Anaconda3 and got the same error above.
Apparently, Python provided by Anaconda sometimes is not working in MATLAB.
I just uninstalled Anaconda3 and install CPython instead and this seems to work.

@AntiLibrary5
Copy link

Install Python (Cpython) from python.org/downloads.
Make sure the version you download is 64-bit if your Matlab exe is 64-bit. By default, a 32-bit cersion of python is downloaded so be careful.
Open python and try the command "import numpy as np". If you get an error, you need to install the library. For this, go to command prompt and type (for python 3): "pip3 install numpy"
Now you will be able to use numpy library in matlab

@irenevigueguix
Copy link

Hey! I've got problems as well to launch Python into MATLAB, and I've successfully made it work (after spending the whole afternoon) by following your instructions together with other info that I found on the internet regarding the same problem with other Python packages. Yay! Also, I've created this tutorial for those who might have the same issues in the future and probably end up on this very page. I hope you find the tutorial useful and clearly explained!

@TomDonoghue
Copy link
Member

Hey @viguix that tutorial blog post looks really cool - would it be okay if I link to it from the README so other people can find it more easily?

Also, sorry for the slow reply here, but if you've been trying out FOOOF through the wrapper or anything and have any questions etc, please do feel free to ask them!

@4srihy
Copy link

4srihy commented Sep 1, 2021

Hi, I got the same error. The easiest solution I found on internet is
first uninstall numpy by pip uninstall numpy
and then install it again with pip install numpy in anaconda command prompt.

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

6 participants