title: cannot import Python modules on R Studio
body: <p>I directly followed the instructions outlined in the website below, to set python virtualenv and install reticulate r package:</p>
  <p><a href="https://support.rstudio.com/hc/en-us/articles/360023654474-Installing-and-Configuring-Python-with-RStudio" rel="nofollow noreferrer">https://support.rstudio.com/hc/en-us/articles/360023654474-Installing-and-Configuring-Python-with-RStudio</a></p>
  <p>In R Markdown chunk, I tried:</p>
  <pre><code>```{r setup, include=FALSE}
  require(reticulate)
  setwd('/Users/hyunjindominiquecho/Desktop/mcmc_intermediate/')
  Sys.setenv(RETICULATE_PYTHON = &quot;python/bin/python&quot;)
  
  </code></pre>
  <p>and</p>
  <pre><code>```{python}
  # import the necessary python packages
  import numpy as np
  import pandas as pd
  import scipy.stats as st
  from rpy2.robjects import pandas2ri
  import math
  from scipy.optimize import newton
  import torch
  from pandas import dataframe
  from statistics import mean 
  </code></pre>
  <p>but I can't import all of the python packages that I want to import (even after installing the modules in my Python virtualenv with the <code>pip install ...</code> command). I am getting the error messages below:</p>
  <pre><code>RRuntimeError: Error in library.dynam(lib, package, package.lib) : 
    shared object ‘methods.dylib’ not found
  
  
  Detailed traceback: 
    File &quot;&lt;string&gt;&quot;, line 1, in &lt;module&gt;
    File &quot;/Users/hyunjindominiquecho/Desktop/mcmc_intermediate/python/lib/python3.7/site-packages/rpy2/robjects/__init__.py&quot;, line 19, in &lt;module&gt;
      from rpy2.robjects.robject import RObjectMixin, RObject
    File &quot;/Users/hyunjindominiquecho/Desktop/mcmc_intermediate/python/lib/python3.7/site-packages/rpy2/robjects/robject.py&quot;, line 58, in &lt;module&gt;
      class RObjectMixin(object):
    File &quot;/Users/hyunjindominiquecho/Desktop/mcmc_intermediate/python/lib/python3.7/site-packages/rpy2/robjects/robject.py&quot;, line 70, in RObjectMixin
      __show = _get_exported_value('methods', 'show')
    File &quot;/Users/hyunjindominiquecho/Desktop/mcmc_intermediate/python/lib/python3.7/site-packages/rpy2/rinterface_lib/conversion.py&quot;, line 44, in _
      cdata = function(*args, **kwargs)
    File &quot;/Users/hyunjindominiquecho/Desktop/mcmc_intermediate/python/lib/python3.7/site-packages/rpy2/rinterface.py&quot;, line 624, in __call__
      raise embedded.RRuntimeError(_rinterface._geterrmessage())
  </code></pre>
  <p>How can I resolve this issue?</p>
  <p>Thank you,</p>