New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
use_condaenv() never uses the specified environment #292
Comments
I suspect that the environment you are trying to use doesn't have numpy in it (and we always prefer environments with NumPy to those without it). Is that the case? |
Hi, thanks for the reply. No, that is not the case. I can import numpy in that environment.
|
Then what's happening is that attempts to load the To get a better error message try: library(reticulate)
use_condaenv(condaenv = 'py27', required = TRUE)
py_run_string('import umap') |
returns
hmmmmm |
Hi everyone, I have been experiencing the same issue as @micdonato Working on this, we found that this is related to some settings of RStudio server (see below post for explanations): Basically, the LD-LIBRARY-PATH variable which points to libstdc++.so.6 from Python does not get honored in RStudio server and Reticulate for some reason. I cannot tweak things on the Rstudio server because it would affect multiple users. Can you guys do something about this on Reticulate? Thanks! |
The LD_LIBRARY_PATH has to be set prior to the process loading so the only way to make this work is to change the configuration of the RStudio Server. |
So, for us this is not a viable option, because it affects ALL users settings. Is there any way for Reticulate to solve this issue, for example through the RETICULATE_PYTHON variable? This should be pretty easy and fixable. |
LD_LIBRARY_PATH has to be established before the process loads so there is nothing that can be done from within R. It has to be done by the process which actually loads R, which in this case is RStudio Server. The RETICULATE_PYTHON variable just determines the version of Python to use, it can't force directories onto the LD_LIBRARY_PATH (again, nothing from within R can do this). |
I see. It is problematic on our end, because the libstdc++.so.6 is also specified by the Python environment one uses. For example, Anaconda2 points to a version of libstdc++.so.6 that is different from the one present at a systems level, and different from the one available in another version of Python. We will try to find a workaround. |
Side note: is there any way to enable user-specific settings for the LD_LIBRARY_PATH used in RStudio server? Based on the documentation, it is not intuitive that it is the case, and of course, we are worried about making changes in RStudio server that could/would affect all users. Thanks a lot for your help @jjallaire |
No, it's a global setting. RStudio Server Pro has support for the PAM session API, which you could use to implement user-specific LD_LIBRARY_PATH. I noted that your GitHub affiliation lists Stanford University -- RStudio Server Pro is free for teaching and 1/2 price for academic research if that helps here. |
We are in touch with customer support (we have a PRO license). Hopefully, we should be able to solve this. Thanks! |
Okay, great. You should be able to define user-specific profiles files that set LD_LIBRARY_PATH or alternatively use PAM to provide user-specific environment variables (I don't know all of the details on that but I know it's possible). These docs are likely to be relevant: http://docs.rstudio.com/ide/server-pro/r-sessions.html#customizing-session-launches |
I can confirm that I'm seeing the same issue with |
On ubuntu 16.04
python versions found:
|
I was able to get
Still can't get |
This thing worked: |
The solution by @kateruksha worked great in my Linux Debian 9. You have to indicate the Python interpreter under the environment bin folder: Then launch your reticulate call to use the conda environment:
WHich will give you this message:
|
Hi,
python: C:/Users/priya/Anaconda3/envs/pyres/python.exe NOTE: Python version was forced by use_python function |
I had a similar issue trying to work the
|
After spending an embarrassingly long time trying to get umap-learn to work, this is literally the ONLY thing that worked for me and was only available since I decided to research the issue again and your reply from a day ago popped up. Thank you SO much! |
Thank you! I had solved my problems by your ways. |
Hi All. I'm experiencing a similar problem but with the bcpandas package... My colleague has written a great function using bcpandas - the problem is installing it so that it's recognized and can be used by the R Reticulate package After a fresh Install of miniconda the packages we need to run his code arent available, so I install them...
After installation however - bcpandas is not available even though I can see it has been installed into the site packages folder,
Do you know why this might be the case? |
Can you confirm that Can you also try running something like:
as this may provide extra information as to why the attempt to import the module is failing. |
Sure! Im not sure actually I needed the \bin\python in my Sys.setenv() call.
... I think this is loaded correctly. So here's the more detailed error message...
|
Thanks! This looks like it may be an issue in the bcpandas module. I found this note on Stackoverflow: which basically suggests that one use |
Ok thanks - good to know as this problem was driving me a little mad! In that case what would be the next steps to resolve? Would this require action by the developer of bcpandas? |
@cjwoodfield: I believe this issue should now be fixed in version 1.0.1 of |
Yes I can import it now. Thanks very much for your help! |
Hi Kevin - Thanks to your fix I can import bcpandas - although when running one of the functions - to_sql - I'm getting a similar handle is invalid error as last time. Wondering whether this issue and the previous issue are linked? To elaborate …. Here is a simplified version of our R App using reticulate...
And Here is the Python file we're running...
And this give a similar Handle is invalid error as before...
I have also notified yehoshuadimarsky on the bcpandas GitHub |
As a further comment - The code above will create a Table on SQL - but not send data |
This probably requires another similar use of |
The fix is in the latest development version. See build |
kateruksha's answer also worked for me. However, it wasn't necessary for me to define
Do note that setting I am using |
I still question the need for setting the environment variable. All that seems to matter is having the environment set at the start of the session. #!/usr/bin/env Rscript
## set conda env 'foo' immediately
reticulate::use_condaenv('foo', required=TRUE)
## business as usual
#... |
We have signifcantly refactored Python discovery order in reticulate v1.31. Please refer to this article and open a new issue if the problem persists. |
Hello,
I've been trying to use reticulate with my conda environments, but it seems that I am not able to load the right environment.
No matter what I put into
use_condaenv()
I always end up with the base conda python version.This is what I am trying:
On the server:
As you can see, the base python (in
~/anaconda2/bin/python
) doesn't have theumap
package installed, while the python in~/anaconda2/envs/py27/python
does.When I open RStudio, I try:
conda_list()
correctly shows all my conda environments.No matter what I put into
use_condaenv()
what I get from py_config is:And since
umap
is installed only onpy27
, I cannot load it with reticulate.Any idea of what I am doing wrong?
The text was updated successfully, but these errors were encountered: