2

I loaded the reticulate package, if it matters.

In a python script in R, the below commands work.

import numpy as np
import pandas as pd 

But this one doesn't

import matplotlib.pyplot as plt

The console says : ModuleNotFoundError: no module named 'matplotlib'

In R's terminal I'm trying to do pip install matplotlib , but I get the error 'pip' is not recognized as an internal or external command, operable program or batch file.

Yeshyyy
  • 669
  • 6
  • 21

1 Answers1

6

I think you need to use the py_install function provided in the reticulate package.

It should work: py_install(packages = "matplotlib")

In case you are using an virtual environment, try the virtualenv_install function.

yarnabrina
  • 1,561
  • 1
  • 10
  • 30
  • great thanks! but i'm getting an error to install 'sklearn. PackagesNotFoundError: The following packages are not available from current channels:' To search for alternate channels that may provide the conda package you're looking for, navigate to https://anaconda.org – Yeshyyy Mar 17 '19 at 09:06
  • I don't know why this is happening. I just tried on a new Rstudio cloud project and it worked fine. Perhaps you should ask a new question, or see here: https://stackoverflow.com/questions/48493505/packagesnotfounderror-the-following-packages-are-not-available-from-current-cha – yarnabrina Mar 17 '19 at 10:25