title: pipenv and rpy2 - Error: Tried to guess R's HOME but no command 'R' in the PATH
body: <p>I'm trying to use pipenv on a data analysis project and have a need to use the <a href="https://github.com/twitter/AnomalyDetection" rel="nofollow noreferrer">Twitter Anomaly Detection package</a> which is in R. </p>
  
  <p>I'm getting an error trying to <code>pipenv install rpy2</code></p>
  
  <p>Below is my code creating a pipenv folder and trying to install rpy2 into it. </p>
  
  <pre><code>PS C:\Users\amaguire\Documents\LocalWork\rp2_pipenv_example&gt; pipenv --python 3.7
  Creating a virtualenv for this project…
  Pipfile: C:\Users\amaguire\Documents\LocalWork\rp2_pipenv_example\Pipfile
  Using C:/Users/amaguire/AppData/Local/Continuum/anaconda3/python.exe (3.7.0) to create virtualenv…
  Running virtualenv with interpreter C:/Users/amaguire/AppData/Local/Continuum/anaconda3/python.exe
  Using base prefix 'C:\\Users\\amaguire\\AppData\\Local\\Continuum\\anaconda3'
  New python executable in C:\Users\amaguire\.virtualenvs\rp2_pipenv_example-MDtFv_K4\Scripts\python.exe
  Installing setuptools, pip, wheel...
  done.
  
  Virtualenv location: C:\Users\amaguire\.virtualenvs\rp2_pipenv_example-MDtFv_K4
  Creating a Pipfile for this project…
  PS C:\Users\amaguire\Documents\LocalWork\rp2_pipenv_example&gt; pipenv install rpy2
  Installing rpy2…
  Collecting rpy2
    Using cached https://files.pythonhosted.org/packages/f1/98/c7652cc9d7fc0afce74d2c30a52b9c9ac391713a63d037e4ab8feb56c530/rpy2-2.9.4.tar.gz
      Complete output from command python setup.py egg_info:
      Error: Tried to guess R's HOME but no command 'R' in the PATH.
  
      ----------------------------------------
  
  Error:  An error occurred while installing rpy2!
  Command "python setup.py egg_info" failed with error code 1 in C:\Users\amaguire\AppData\Local\Temp\pip-install-8h23my82\rpy2\
  
  This is likely caused by a bug in rpy2. Report this to its maintainers.
  PS C:\Users\amaguire\Documents\LocalWork\rp2_pipenv_example&gt;
  </code></pre>
  
  <p>I had a look but could not find much by way of examples of people using rpy2 in a virtualenv or with pipenv. </p>
  
  <p>Am curious as to if anytihng i can do to make rpy2 in the virtualenv know where R lives (if that is whats going on). </p>
  
  <p>Any advice much appreciated, i'd imagine could be useful for others too to try solve this one.  </p>
  
  <h3>Update</h3>
  
  <p>I have added R to my Path variables in windows and am now getting a new error as below. So am hopeful this should solve it once i download Visual C++</p>
  
  <pre><code>        ...
  copying .\rpy\ipython\html.py -&gt; build\lib.win-amd64-3.7\rpy2\ipython
          copying .\rpy\ipython\rmagic.py -&gt; build\lib.win-amd64-3.7\rpy2\ipython
          copying .\rpy\ipython\__init__.py -&gt; build\lib.win-amd64-3.7\rpy2\ipython
          creating build\lib.win-amd64-3.7\rpy2\ipython\tests
          copying .\rpy\ipython\tests\test_rmagic.py -&gt; build\lib.win-amd64-3.7\rpy2\ipython\tests
          copying .\rpy\ipython\tests\__init__.py -&gt; build\lib.win-amd64-3.7\rpy2\ipython\tests
          warning: build_py: byte-compiling is disabled, skipping.
  
          running build_clib
          building 'r_utils' library
          error: Microsoft Visual C++ 14.0 is required. Get it with "Microsoft Visual C++ Build Tools": https://visualstudio.microsoft.com/downloads/
  
          ----------------------------------------
  
      Error:  An error occurred while installing rpy2==2.9.4!
        Failed building wheel for rpy2
      Command "c:\users\amaguire\.virtualenvs\ami-swtbbbw7\scripts\python.exe -u -c "import setuptools, tokenize;__file__='C:\\Users\\amaguire\\AppData\\Local\\Temp\\pip-install-kmzhepx1\\rpy2\\setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record C:\Users\amaguire\AppData\Local\Temp\pip-record-zgsh7n25\install-record.txt --single-version-externally-managed --compile --install-headers c:\users\amaguire\.virtualenvs\ami-swtbbbw7\include\site\python3.7\rpy2" failed with error code 1 in C:\Users\amaguire\AppData\Local\Temp\pip-install-kmzhepx1\rpy2\
  </code></pre>