Wang
Wang

Reputation: 1460

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.

Upvotes: 3

Views: 3499

Answers (1)

Ferroao
Ferroao

Reputation: 3066

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"])

Upvotes: 1

Related Questions