This video has been a lifesaver!!! I basically typed out my entire assignment using a Jupyter notebook with loads of LaTeX equations, and then when I went to add in my code chunks they just never ran... I followed your instructions and then they did! Thank you very much for the clear and concise video
I installed the MATLAB kernel to use MATLAB in jupyter notebook. However, when I try to type and execute commands such as disp('Hello World'), Jupyter doesn't execute the commands. It just shows on the left as In [*]: , the star inside the bracket indicating that the command is executing but not finishing and thus not displaying the output.
Error connecting to MATLAB. Check the status of MATLAB by clicking the "Open MATLAB" button. Retry after ensuring MATLAB is running successfully getting this error when i run
No difference. Anaconda is nice because most of the packages are bundled and are all compatible. Many times they are one minor release back (3.7 vs. 3.8) because it takes a while for all of the packages to make it up to the next release. However, this means that they are all compatible with the first install.
@@apm Thank you, I just did this however I still cannot open jupyter lab or notebook because it says it is not recognized. I'm trying to add the directory to PATH but I'm new to this lol.
Thank you very much for the tutorial. Helped me a lot ! However, I wish you added a small section for people who do not have admin privileges. Here is how I installed it: 1) Pip,conda will not work in command prompt,so download and install the anaconda for jupyter. 2) If you need to install packages with pip or conda, install it via Anaconda powershell. 3) As of now mathlab uses python 3.7 if you use 3.8 or 3.9 you can not install python engines, so install python 3.7. 4) This installation will demand admin privileges but you can also install it with: python setup.py build -b C:\Temp install. Cheers !
What advantages does this have over matlab's live script editor? Also, does this have much overhead relative to programming natively? Nonetheless, thanks for sharing an alternative. It's great to have options!
Hey, I have already installed Anaconda Navigator and has python 3.8 in all envs and it showed that I need either python 3.6 or 3.7 to download the setup.py in the step. So I created an env in Anaconda wth python 3.6 but the command promp still shows I am working with python 3.8 How can I change it from one env to other ?
Thank you for nice job. I am interested in knowing that if possible we call a matlab function (m.file) inside of a part of matlab code written in jupyter notebook. If yes, where should we save our m-file?
Yes, you can call functions that are stored as .m files. You can put the .m file in your run directory where you also store the Jupyter notebook. More examples are here: apmonitor.github.io/begin_matlab
@@apm I followed one example of Function.ipynb. It does not work for me. Actually defining function as function y = double_it(x) y = x*2; end in one code cell and call it in next step is faced with this error: " Error: Function definition not supported in this context. Create functions in code file. " I defined in code cell something like: %%file double_it.m function y = double_it(x) y = x*2; end and call it with succeed in result. (it makes a m.file in directory as you mentioned...) I followed this method for my own function. I am initializing my FC network with He method as bellow: in code cell: %%file initializer_He_uniform.m function W = initializer_He_uniform(L_in, L_out) epsilon_init = sqrt( 6/(L_in + L_out) ); a = -epsilon_init; b = epsilon_init; W = (b-a).*rand([L_out, L_in + 1]) + a; end then call it with: ... W1 = initializer_He_uniform(n1,n2); w = W1(:); ... I frequently encountered with this warning: " The save operation succeeded, but the notebook does not appear to be valid. The validation error was: Notebook validation failed: -1 is not of type 'string': -1 " I cannot even save my job for this warning. Have you ever seen this error? what is the meaning of that?
@@apm @APMonitor.com Nothing! The latest one, R2020b. I am using deep learning toolbox (costum training loop, dlnet) because I have a new optimizer (alternative for sgd or adam) to train my CNN. For knowing about my algorithm's performance with and without minibatch, at the moment I want to use all my 600000 images 28by28 as full batch not minibatch. The function gpuarray can not accept because of my gpu limitation. After your video, I thought it is better I use matlab in jupyter so that I use jupyter through google colab with free gpu. But unfortunately all my m-files faced with this warning. In matlab they run trully. If I could solve this problem I would continue with matlab itself. By the way, If you have any suggestion to use matlab in environment such as google colab to use my required capacity of gpu, I would really appreciated it. Maybe there are more easier solutions.
Thank you so much... I always wanted to use Matlab in Jupyter Notebook via VS code, cuz I love to work in dark theme and use code snippets. It finally worked. However, when I make any error in my code, it shows an error message and goes on executing until I have to manually stop the kernel and restart it. Is there any way to handle this issue?
@@apm what path remnant should i look for? and what should i change it too in your video you have python38 but how do i do it since i have anaconda and python 27
After multiple attempts this is my observation 1. Works with Python version 3.8 to 3.11 2. Works with MATLAB 2020a to 2022b. Failed to work with 2023 version. 3. If you see [ ] turn into [*] in jupyter notebook. Do wait for a few minutes since it takes sometime to setup the MATLAB kernel initially. You will eventually see the output. Cheers! Thanks for this great series Prof.John!
one question.. Which version of MATLAB can be run in Jupyter properly? everything was ok till the time for cell running. I also check the keyboard shortcut in Jupyter. The codes can not be run. It seems that you just are typing in Jupyter. I noticed that when each cell runs, the "In [ ]" will turn to "In [ Number ]". But not for me.. it s just stay on "In [ * ]". Thank you in advance for your guidance.
I also applied the simple code on Jupyter Lab using different shortcuts ( "Enter", "Enter+Ctrl", "Shift", "Shift+Enter" and etc.). And also the Run button on top of the code environment. I unfortunately use MATLAB 2013b. Can this problem refers to the version of MATLAB?
@@Tatanajafi It won't work with MATLAB 2013b. I think you need at least 2017. Here is a complete course if you'd like to use Octave instead: apmonitor.github.io/begin_matlab If you have access to Matlab Online, you can also run Live Scripts through the online interface.
@@reggaetonoldschool3197 it should work in R2019a. You may have a problem with your Python install, PATH variable, or other issue. I recommend that you uninstall Python and try it again, following the setup instructions exactly.
@@apm The problem is that when we run the command python setup.py install, it gives an error, the error it gives it "Matlab engine for Python support Python version 2.7, 3.5, 3.6 and 3.7, but your version of Python is 3.8" So your saying it should work, however, you I get the following error above when running that command so i cannot move to the next step? any suggestions would be appreciated, i don't want to go install a lower version of python.
@@MrKhanRizwan unfortunately, the Python version is determined by MathWorks. You can have multiple distributions of Python on your computer. You'll just need to add to the PATH variable if you'd like to use one or the other. You can also upgrade your MATLAB version for Python 3.8 compatibility. It appears that R2020 supports Python 3.8: www.mathworks.com/help/matlab/matlab_external/install-supported-python-implementation.html
Go ahead and post your question here or else on StackOverflow. That way, others can also respond and benefit from the question. If it is a specific question with a request for support, I get too many requests for help each week to answer them.
Hi, I am running the setup.py as administrator and opened the command line as administrator and get the following error: Access Denied. Any idea how to get around this? error: could not create 'C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.8_3.8.1776.0_x64__qbz5n2kfra8p0\Lib\site-packages\matlab': Access is denied
You may want to install a different version of Python. It appears that the Windows App version of Python does not give you access. Here are instructions on installing Python from Python.org: apmonitor.com/pdc/index.php/Main/InstallPython
This video has been a lifesaver!!! I basically typed out my entire assignment using a Jupyter notebook with loads of LaTeX equations, and then when I went to add in my code chunks they just never ran... I followed your instructions and then they did! Thank you very much for the clear and concise video
I'm glad it helped!
This is an excellent tutorial. Thank you so much sir !!!!
I installed the MATLAB kernel to use MATLAB in jupyter notebook. However, when I try to type and execute commands such as disp('Hello World'), Jupyter doesn't execute the commands. It just shows on the left as In [*]: , the star inside the bracket indicating that the command is executing but not finishing and thus not displaying the output.
Sorry it didn't work. Maybe try the install script again?
Same problem here. Were you able to solve it?
@@shahriarakbar3102 no i didn't.
@@AJ-et3vf It worked finally!
@@shahriarakbar3102 How did you do it? I have the same problem
Where does the Octave executable live in Linux?
Try "where octave" in the command line.
Thank you very much. Excellent tutorial
Error connecting to MATLAB. Check the status of MATLAB by clicking the "Open MATLAB" button. Retry after ensuring MATLAB is running successfully
getting this error when i run
Thanks for highlighting that issue. Please try Octave or Python if Matlab doesn't work.
Thank you, this helped me a lot
I installed matlab_kernel and i see it when i do a pip list, but i do not see the MATLAB option in my jupyter notebook
Do you have multiple versions of Python installed? You may need to restart Jupyter notebook, the kernel, and don't forget the Python setup at 4:10.
Thank you for the video! Is there any differences in installation when you use Jupyter from Anaconda?
No difference. Anaconda is nice because most of the packages are bundled and are all compatible. Many times they are one minor release back (3.7 vs. 3.8) because it takes a while for all of the packages to make it up to the next release. However, this means that they are all compatible with the first install.
APMonitor.com thanks!
Just got python but its 3.11 and Matlab engine says it doesn't support it yet
what could I do to navigate past this issue
You will need to install an earlier version of Python that is supported.
@@apm Thank you, I just did this however I still cannot open jupyter lab or notebook because it says it is not recognized. I'm trying to add the directory to PATH but I'm new to this lol.
@@drewmo4673 Here are more details on installing Python: apmonitor.com/dde/index.php/Main/InstallPython
Thank you very much for the tutorial. Helped me a lot !
However, I wish you added a small section for people who do not have admin privileges.
Here is how I installed it:
1) Pip,conda will not work in command prompt,so download and install the anaconda for jupyter.
2) If you need to install packages with pip or conda, install it via Anaconda powershell.
3) As of now mathlab uses python 3.7 if you use 3.8 or 3.9 you can not install python engines, so install python 3.7.
4) This installation will demand admin privileges but you can also install it with: python setup.py build -b C:\Temp install.
Cheers !
Thanks for the helpful tips. Another way to install without admin privilege is to use the --user flag such as pip install numpy --user
What advantages does this have over matlab's live script editor?
Also, does this have much overhead relative to programming natively?
Nonetheless, thanks for sharing an alternative. It's great to have options!
Live Script is probably better, but this is a nice alternative if you like Jupyter notebooks.
Hey, I have already installed Anaconda Navigator and has python 3.8 in all envs and it showed that I need either python 3.6 or 3.7 to download the setup.py in the step. So I created an env in Anaconda wth python 3.6 but the command promp still shows I am working with python 3.8 How can I change it from one env to other ?
Change your environment variable PATH to switch to a different default install.
Thanks man
Thank you for nice job. I am interested in knowing that if possible we call a matlab function (m.file) inside of a part of matlab code written in jupyter notebook. If yes, where should we save our m-file?
Yes, you can call functions that are stored as .m files. You can put the .m file in your run directory where you also store the Jupyter notebook. More examples are here: apmonitor.github.io/begin_matlab
@@apm I followed one example of Function.ipynb. It does not work for me. Actually defining function as
function y = double_it(x)
y = x*2;
end
in one code cell and call it in next step is faced with this error:
" Error: Function definition not supported in this context. Create functions in code file.
"
I defined in code cell something like:
%%file double_it.m
function y = double_it(x)
y = x*2;
end
and call it with succeed in result. (it makes a m.file in directory as you mentioned...)
I followed this method for my own function. I am initializing my FC network with He method as bellow:
in code cell:
%%file initializer_He_uniform.m
function W = initializer_He_uniform(L_in, L_out)
epsilon_init = sqrt( 6/(L_in + L_out) );
a = -epsilon_init;
b = epsilon_init;
W = (b-a).*rand([L_out, L_in + 1]) + a;
end
then call it with:
...
W1 = initializer_He_uniform(n1,n2);
w = W1(:);
...
I frequently encountered with this warning:
" The save operation succeeded, but the notebook does not appear to be valid. The validation error was:
Notebook validation failed: -1 is not of type 'string':
-1 "
I cannot even save my job for this warning. Have you ever seen this error? what is the meaning of that?
@@mahsayousefi99 sorry - I haven't seen this error. What version of Matlab are you using?
@@apm @APMonitor.com Nothing!
The latest one, R2020b. I am using deep learning toolbox (costum training loop, dlnet) because I have a new optimizer (alternative for sgd or adam) to train my CNN. For knowing about my algorithm's performance with and without minibatch, at the moment I want to use all my 600000 images 28by28 as full batch not minibatch. The function gpuarray can not accept because of my gpu limitation. After your video, I thought it is better I use matlab in jupyter so that I use jupyter through google colab with free gpu. But unfortunately all my m-files faced with this warning. In matlab they run trully. If I could solve this problem I would continue with matlab itself. By the way, If you have any suggestion to use matlab in environment such as google colab to use my required capacity of gpu, I would really appreciated it. Maybe there are more easier solutions.
@@mahsayousefi5085 unfortunately Matlab isn't available through colab. That sounds like an interesting application.
Thank you so much... I always wanted to use Matlab in Jupyter Notebook via VS code, cuz I love to work in dark theme and use code snippets. It finally worked. However, when I make any error in my code, it shows an error message and goes on executing until I have to manually stop the kernel and restart it. Is there any way to handle this issue?
Try searching for the error or posting the error to StackOverflow.
in program fles its showing error
What's the specific error message? Try searching for it on StackOverflow or other online sources.
hey I hve this issue where i have an older version of matlab on my computer so it doesnt work what should i do
I use to have it working when i needed it in 2017 i hve matlab 2020
@@drummytbone23 it should work with Matlab 2020. If it doesn't work then there are Octave instructions that run equivalently to Matlab.
@@apm theres an issue where i think its still linked to my old matlab how do i change it
@@drummytbone23 does it help to uninstall the old matlab version? You may also want to check your environment variables for a PATH remnant.
@@apm what path remnant should i look for? and what should i change it too in your video you have python38 but how do i do it since i have anaconda and python 27
After multiple attempts this is my observation
1. Works with Python version 3.8 to 3.11
2. Works with MATLAB 2020a to 2022b. Failed to work with 2023 version.
3. If you see [ ] turn into [*] in jupyter notebook. Do wait for a few minutes since it takes sometime to setup the MATLAB kernel initially. You will eventually see the output.
Cheers! Thanks for this great series Prof.John!
Thanks for that additional information.
one question.. Which version of MATLAB can be run in Jupyter properly? everything was ok till the time for cell running. I also check the keyboard shortcut in Jupyter. The codes can not be run. It seems that you just are typing in Jupyter. I noticed that when each cell runs, the "In [ ]" will turn to "In [ Number ]". But not for me.. it s just stay on "In [ * ]". Thank you in advance for your guidance.
I also applied the simple code on Jupyter Lab using different shortcuts ( "Enter", "Enter+Ctrl", "Shift", "Shift+Enter" and etc.). And also the Run button on top of the code environment. I unfortunately use MATLAB 2013b. Can this problem refers to the version of MATLAB?
@@Tatanajafi It won't work with MATLAB 2013b. I think you need at least 2017. Here is a complete course if you'd like to use Octave instead: apmonitor.github.io/begin_matlab If you have access to Matlab Online, you can also run Live Scripts through the online interface.
did you solve it? I have the same problem with the R2019a version
@@reggaetonoldschool3197 it should work in R2019a. You may have a problem with your Python install, PATH variable, or other issue. I recommend that you uninstall Python and try it again, following the setup instructions exactly.
Gracias !!
Please demo the same thing in Linux!
Thanks for the recommendation.
OSError: MATLAB Engine for Python supports Python version 2.7,3.5, 3.6, and 3.7, butyour version of Python is 3.8
I'm using Matlab 2020a and it is compatible with Python 3.8. If you have a slightly older version of Matlab then you may need to use Python 3.7.
@@apm R2019A 😢
Python 3.7 or 3.6 should work well. Python 3.7 is the one that Anaconda currently distributes.
@@apm The problem is that when we run the command python setup.py install, it gives an error, the error it gives it "Matlab engine for Python support Python version 2.7, 3.5, 3.6 and 3.7, but your version of Python is 3.8"
So your saying it should work, however, you I get the following error above when running that command so i cannot move to the next step?
any suggestions would be appreciated, i don't want to go install a lower version of python.
@@MrKhanRizwan unfortunately, the Python version is determined by MathWorks. You can have multiple distributions of Python on your computer. You'll just need to add to the PATH variable if you'd like to use one or the other. You can also upgrade your MATLAB version for Python 3.8 compatibility. It appears that R2020 supports Python 3.8: www.mathworks.com/help/matlab/matlab_external/install-supported-python-implementation.html
Sir I need some help from you plz reply me sir
Go ahead and post your question here or else on StackOverflow. That way, others can also respond and benefit from the question. If it is a specific question with a request for support, I get too many requests for help each week to answer them.
Hi,
I am running the setup.py as administrator and opened the command line as administrator and get the following error: Access Denied.
Any idea how to get around this?
error: could not create 'C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.8_3.8.1776.0_x64__qbz5n2kfra8p0\Lib\site-packages\matlab': Access is denied
I have the same problem when running setup.py script. Python 3.8 with Matlab 2020b.
You may want to install a different version of Python. It appears that the Windows App version of Python does not give you access. Here are instructions on installing Python from Python.org: apmonitor.com/pdc/index.php/Main/InstallPython
@@apm You were right about the Window App version of Python. It works now. Thanks!
@@apm Thank you - this works now!
Cursed
It didn't work for you? Let us know the error that you encountered or search for it on StackOverflow.