Matlab in Jupyter Lab Notebook

Поделиться
HTML-код
  • Опубликовано: 16 янв 2025

Комментарии • 77

  • @ameliadunstone2999
    @ameliadunstone2999 4 года назад +4

    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

    • @apm
      @apm  4 года назад

      I'm glad it helped!

  • @mathew9710
    @mathew9710 2 года назад +2

    This is an excellent tutorial. Thank you so much sir !!!!

  • @AJ-et3vf
    @AJ-et3vf 3 года назад +4

    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.

    • @apm
      @apm  3 года назад

      Sorry it didn't work. Maybe try the install script again?

    • @shahriarakbar3102
      @shahriarakbar3102 3 года назад +1

      Same problem here. Were you able to solve it?

    • @AJ-et3vf
      @AJ-et3vf 3 года назад

      @@shahriarakbar3102 no i didn't.

    • @shahriarakbar3102
      @shahriarakbar3102 3 года назад

      @@AJ-et3vf It worked finally!

    • @anajimenajuarezsandoval5583
      @anajimenajuarezsandoval5583 2 года назад

      @@shahriarakbar3102 How did you do it? I have the same problem

  • @jerrymalone8370
    @jerrymalone8370 2 года назад +1

    Where does the Octave executable live in Linux?

    • @apm
      @apm  2 года назад

      Try "where octave" in the command line.

  • @neighborhoodguy7565
    @neighborhoodguy7565 3 года назад +2

    Thank you very much. Excellent tutorial

  • @hiccup_9838
    @hiccup_9838 Год назад +1

    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

    • @apm
      @apm  Год назад

      Thanks for highlighting that issue. Please try Octave or Python if Matlab doesn't work.

  • @ajaisingh9129
    @ajaisingh9129 3 года назад +2

    Thank you, this helped me a lot

  • @ashimg4806
    @ashimg4806 4 года назад +2

    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

    • @apm
      @apm  4 года назад

      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.

  • @trashchenkov
    @trashchenkov 4 года назад +3

    Thank you for the video! Is there any differences in installation when you use Jupyter from Anaconda?

    • @apm
      @apm  4 года назад +2

      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.

    • @trashchenkov
      @trashchenkov 4 года назад +1

      APMonitor.com thanks!

  • @drewmo4673
    @drewmo4673 2 года назад +1

    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

    • @apm
      @apm  2 года назад +1

      You will need to install an earlier version of Python that is supported.

    • @drewmo4673
      @drewmo4673 2 года назад +1

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

    • @apm
      @apm  2 года назад +1

      @@drewmo4673 Here are more details on installing Python: apmonitor.com/dde/index.php/Main/InstallPython

  • @drcemdede
    @drcemdede 3 года назад +1

    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 !

    • @apm
      @apm  3 года назад +1

      Thanks for the helpful tips. Another way to install without admin privilege is to use the --user flag such as pip install numpy --user

  • @willingoYT
    @willingoYT 2 года назад +1

    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!

    • @apm
      @apm  2 года назад

      Live Script is probably better, but this is a nice alternative if you like Jupyter notebooks.

  • @jithindmathew2597
    @jithindmathew2597 4 года назад +2

    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 ?

    • @apm
      @apm  4 года назад

      Change your environment variable PATH to switch to a different default install.

  • @usama57926
    @usama57926 3 года назад +2

    Thanks man

  • @mahsayousefi99
    @mahsayousefi99 4 года назад +2

    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?

    • @apm
      @apm  4 года назад +2

      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

    • @mahsayousefi99
      @mahsayousefi99 4 года назад +1

      @@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
      @apm  4 года назад +1

      @@mahsayousefi99 sorry - I haven't seen this error. What version of Matlab are you using?

    • @mahsayousefi5085
      @mahsayousefi5085 4 года назад +1

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

    • @apm
      @apm  4 года назад +1

      @@mahsayousefi5085 unfortunately Matlab isn't available through colab. That sounds like an interesting application.

  • @shahriarakbar3102
    @shahriarakbar3102 3 года назад +1

    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
      @apm  3 года назад +1

      Try searching for the error or posting the error to StackOverflow.

  • @anishabanerjee379
    @anishabanerjee379 2 года назад +1

    in program fles its showing error

    • @apm
      @apm  2 года назад

      What's the specific error message? Try searching for it on StackOverflow or other online sources.

  • @drummytbone23
    @drummytbone23 4 года назад

    hey I hve this issue where i have an older version of matlab on my computer so it doesnt work what should i do

    • @drummytbone23
      @drummytbone23 4 года назад +1

      I use to have it working when i needed it in 2017 i hve matlab 2020

    • @apm
      @apm  4 года назад

      @@drummytbone23 it should work with Matlab 2020. If it doesn't work then there are Octave instructions that run equivalently to Matlab.

    • @drummytbone23
      @drummytbone23 4 года назад +1

      @@apm theres an issue where i think its still linked to my old matlab how do i change it

    • @apm
      @apm  4 года назад

      @@drummytbone23 does it help to uninstall the old matlab version? You may also want to check your environment variables for a PATH remnant.

    • @drummytbone23
      @drummytbone23 4 года назад +1

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

  • @jyothiradityar6455
    @jyothiradityar6455 Год назад +1

    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!

    • @apm
      @apm  Год назад

      Thanks for that additional information.

  • @Tatanajafi
    @Tatanajafi 4 года назад

    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.

    • @Tatanajafi
      @Tatanajafi 4 года назад

      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?

    • @apm
      @apm  4 года назад

      @@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
      @reggaetonoldschool3197 4 года назад +2

      did you solve it? I have the same problem with the R2019a version

    • @apm
      @apm  4 года назад

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

  • @AZUCENATorres-gy8zi
    @AZUCENATorres-gy8zi 3 месяца назад

    Gracias !!

  • @jerrymalone8370
    @jerrymalone8370 2 года назад +1

    Please demo the same thing in Linux!

    • @apm
      @apm  2 года назад +1

      Thanks for the recommendation.

  • @satyam-talks
    @satyam-talks 4 года назад +2

    OSError: MATLAB Engine for Python supports Python version 2.7,3.5, 3.6, and 3.7, butyour version of Python is 3.8

    • @apm
      @apm  4 года назад

      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.

    • @satyam-talks
      @satyam-talks 4 года назад +1

      @@apm R2019A 😢

    • @apm
      @apm  4 года назад

      Python 3.7 or 3.6 should work well. Python 3.7 is the one that Anaconda currently distributes.

    • @MrKhanRizwan
      @MrKhanRizwan 4 года назад +1

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

    • @apm
      @apm  4 года назад

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

  • @walidlatif6276
    @walidlatif6276 4 года назад

    Sir I need some help from you plz reply me sir

    • @apm
      @apm  4 года назад

      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.

  • @alisonspera2461
    @alisonspera2461 4 года назад

    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

    • @tonyhope1291
      @tonyhope1291 4 года назад +1

      I have the same problem when running setup.py script. Python 3.8 with Matlab 2020b.

    • @apm
      @apm  4 года назад +2

      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

    • @antancybersecurity5926
      @antancybersecurity5926 4 года назад +1

      @@apm You were right about the Window App version of Python. It works now. Thanks!

    • @alisonspera1955
      @alisonspera1955 4 года назад +1

      @@apm Thank you - this works now!

  • @grahamspellman2442
    @grahamspellman2442 4 года назад +1

    Cursed

    • @apm
      @apm  4 года назад

      It didn't work for you? Let us know the error that you encountered or search for it on StackOverflow.