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

57 次查看(过去 30 天)
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?

采纳的回答

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

更多回答(0 个)

类别

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