Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

install Python modules in Rstudio

I am trying to run python 3.8 in Rstudio using mac system. However, I am confused about installing modules using reticulate. When I install scipy using py_install("scipy"), I can install it successfully. However, when I test its availability, I got FALSE output, and therefore, I cannot import scipy module.

library(reticulate)
use_python("/usr/local/bin/python3")
py_available() # TRUE
py_install("scipy") # installed sucessfully
py_module_available("scipy") # FALSE

If i use sudo pip install scipy in R terminal, I can successfully install it and import it. Can somebody explain why i cannot install Python module using py_install?

Thanks a lot.

like image 648
Wang Avatar asked Jun 28 '26 14:06

Wang


1 Answers

Maybe this "answer" works for people arriving here based on OP title; works also in jupyter

import os
os.system("pip3 install pandas")

Or:

import subprocess
subprocess.call('pip3 install pytesseract'.split())

or:

import subprocess
subprocess.call(['pip3', 'install', "pandas"])
like image 154
Ferroao Avatar answered Jul 01 '26 04:07

Ferroao