title: Module 'scipy.sparse' has no attribute 'linalg' error in reticulate virtual environment
body: <p>I have written a function which works exactly as I would like it to in python, but when I try and run it in R I run into a problem with reticulate. I have troubleshooted this problem and have reduced it down to this problem. I have this function in python:</p>
  <pre><code>def get_largest_eigenvalue(inc_mat):
      eigen_val = scipy.sparse.linalg.eigs(inc_mat, k = 1)
      eigen_val = eigen_val[0] / inc_mat.shape[0]
      return eigen_val
  </code></pre>
  <p>Essentially this function takes a csr_matrix and returns its largest eigenvalue. It should work for any csr_matrix. I get an error when I run this code using reticulate and solving this will solve my larger problem.</p>
  <p>To run this code in reticulate I run</p>
  <pre><code>library(reticulate)
  use_virtualenv(&quot;default&quot;)
  </code></pre>
  <p>I have previously run this code to install scipy to this virtual environment</p>
  <pre><code>virtualenv_install(&quot;default&quot;, c(&quot;scipy&quot;))
  </code></pre>
  <p>I have then used</p>
  <pre><code>source_python(&quot;file_name.py&quot;)
  </code></pre>
  <p>To load all of my python functions, including the one above. All of the other functions I have loaded work perfectly except the one above. When I try and run it I receive the following error</p>
  <blockquote>
  <p>Error in py_call_impl(callable, dots$args, dots$keywords) :
  AttributeError: module 'scipy.sparse' has no attribute 'linalg'</p>
  </blockquote>
  <p>I am a bit out of my depth here and I have tried running code like</p>
  <pre><code>virtualenv_install(&quot;default&quot;, c(&quot;scipy.sparse&quot;))
  </code></pre>
  <p>But this causes more errors and does not work. Any help would be appreciated! Thank you!</p>