How can I use pip to install Python libraries in MATLAB Online environment?

조회 수: 58 (최근 30일)
Angelo Yeo
Angelo Yeo 2024년 10월 18일
답변: Angelo Yeo 2024년 10월 18일
I want to use Python codes in MATLAB Online. However, MATLAB Online environment does not provide "pip" command as it is.
!python -m pip install numpy panda
/usr/bin/python: No module named pip
How can I install additional Python libraries in MALTAB Online environment?

답변 (1개)

Angelo Yeo
Angelo Yeo 2024년 10월 18일
You can download a certain Python script that helps you install pip environment first.
websave("get-pip.py","https://bootstrap.pypa.io/get-pip.py");
!python get-pip.py
Defaulting to user installation because normal site-packages is not writeable Collecting pip Downloading pip-24.2-py3-none-any.whl.metadata (3.6 kB) Collecting setuptools Downloading setuptools-75.2.0-py3-none-any.whl.metadata (6.9 kB) Collecting wheel Downloading wheel-0.44.0-py3-none-any.whl.metadata (2.3 kB) Downloading pip-24.2-py3-none-any.whl (1.8 MB) □[?25l □[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━□[0m □[32m0.0/1.8 MB□[0m □[31m?□[0m eta □[36m-:--:--□[0m □[2K □[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━□[0m □[32m1.8/1.8 MB□[0m □[31m146.8 MB/s□[0m eta □[36m0:00:00□[0m □[?25hDownloading setuptools-75.2.0-py3-none-any.whl (1.2 MB) □[?25l □[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━□[0m □[32m0.0/1.2 MB□[0m □[31m?□[0m eta □[36m-:--:--□[0m □[2K □[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━□[0m □[32m1.2/1.2 MB□[0m □[31m141.7 MB/s□[0m eta □[36m0:00:00□[0m □[?25hDownloading wheel-0.44.0-py3-none-any.whl (67 kB) Installing collected packages: wheel, setuptools, pip □[33m WARNING: The script wheel is installed in '/home/matlab/.local/bin' which is not on PATH. Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.□[0m□[33m □[0m□[33m WARNING: The scripts pip, pip3 and pip3.10 are installed in '/home/matlab/.local/bin' which is not on PATH. Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.□[0m□[33m □[0mSuccessfully installed pip-24.2 setuptools-75.2.0 wheel-0.44.0
!python -m pip --version
pip 24.2 from /home/matlab/.local/lib/python3.10/site-packages/pip (python 3.10)
Then, you can now install Python libraries via pip as such:
!python -m pip install numpy
Defaulting to user installation because normal site-packages is not writeable Collecting numpy Downloading numpy-2.1.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata (60 kB) Downloading numpy-2.1.2-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (16.3 MB) □[?25l □[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━□[0m □[32m0.0/16.3 MB□[0m □[31m?□[0m eta □[36m-:--:--□[0m □[2K □[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━□[0m □[32m16.3/16.3 MB□[0m □[31m232.0 MB/s□[0m eta □[36m0:00:00□[0m □[?25hInstalling collected packages: numpy □[33m WARNING: The scripts f2py and numpy-config are installed in '/home/matlab/.local/bin' which is not on PATH. Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.□[0m□[33m □[0mSuccessfully installed numpy-2.1.2

카테고리

Help CenterFile Exchange에서 Call Python from MATLAB에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by