import error
Closed this issue · 7 comments
Hi and thanks for the nice package.
I cannot import anndata2ri. I just created a new conda environment with python3.8 and installed R. I also installed anndata2ri with pip (conda failed AND failed to backtrace the error...). When trying to import the package, I get a long backtrace that ends with:
...
~/anaconda3/envs/scconvert/lib/python3.8/site-packages/rpy2/rinterface_lib/sexp.py in __getitem__(self, key)
353 # TODO: move check of R_UnboundValue to _rinterface
354 if res == openrlib.rlib.R_UnboundValue:
--> 355 raise KeyError("'%s' not found" % key)
356 return res
357
KeyError: "'str2lang' not found"
Any help to get this to work would be greatly appreciated.
Can you please give me a minimal reproducible example as well as the full stack trace? Otherwise I can’t help you.
Thank you, here the code of how I got this:
$ conda create -n myenv python=3.8
$ conda activate myenv
$ conda install R
$ conda install -c bioconda anndata2ri
Solving environment: -
Found conflicts! Looking for incompatible packages.
This can take several minutes. Press CTRL-C to abort.
failed
UnsatisfiableError: The following specifications were found to be incompatible with each other:
Output in format: Requested package -> Available versions
then I tried to install with pip:
$ pip install anndata2ri
python
Python 3.8.2 (default, Mar 26 2020, 15:53:00)
[GCC 7.3.0] :: Anaconda, Inc. on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import anndata2ri
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/fabio/anaconda3/envs/myenv/lib/python3.8/site-packages/anndata2ri/__init__.py", line 20, in <module>
from .conv import converter, activate, deactivate
File "/home/fabio/anaconda3/envs/myenv/lib/python3.8/site-packages/anndata2ri/conv.py", line 3, in <module>
from rpy2.robjects import conversion, numpy2ri, pandas2ri, default_converter, SexpVector
File "/home/fabio/anaconda3/envs/myenv/lib/python3.8/site-packages/rpy2/robjects/__init__.py", line 27, in <module>
from . import language
File "/home/fabio/anaconda3/envs/myenv/lib/python3.8/site-packages/rpy2/robjects/language.py", line 16, in <module>
_str2lang = ri.baseenv['str2lang']
File "/home/fabio/anaconda3/envs/myenv/lib/python3.8/site-packages/rpy2/rinterface_lib/conversion.py", line 44, in _
cdata = function(*args, **kwargs)
File "/home/fabio/anaconda3/envs/myenv/lib/python3.8/site-packages/rpy2/rinterface_lib/_rinterface_capi.py", line 282, in _
robj = function(*args, **kwargs)
File "/home/fabio/anaconda3/envs/myenv/lib/python3.8/site-packages/rpy2/rinterface_lib/sexp.py", line 355, in __getitem__
raise KeyError("'%s' not found" % key)
KeyError: "'str2lang' not found"
Now since you are not testing python 3.8 on Travis, I repeated the spiel on Python 3.7.7, same errors (both on the conda install and on the import after pip install).
My guess is that this package should require a specific version of rpy2 and/or R to go be paired with?
Maybe you could extend your Travis build matrix to include installing R within a conda environment instead of globally?
Having semi-insulated environment is one major reason why people use conda in the first place, since having to juggle 5 different versions of R on the same server is not great.
If you are interested you can have a look at how I usually do these things using manylinux2010 and OSX + conda, could be useful here too: https://travis-ci.org/github/htseq/htseq/builds/677026670
Conda is being weird; after “The following specifications were found to be incompatible with each other:” should be something, you should probably report that bug with them.
For the pip route, the error happens when importing rpy2, so
-
please check where the problem happens before reporting a bug somewhere. the stack trace clearly tells you that the last anndata2ri line that’s involved is
rpy2.robjects import conversion, numpy2ri, pandas2ri, default_converter, SexpVector
which clearly means that it’s not a anndata2ri bug.
-
if you google “str2lang”, you’ll find that it has been added in R 3.6.0. I strongly assume that you should simply update your R to make rpy2 work. If you think rpy2 should work with older R versions, please report an issue there
done: https://github.com/theislab/anndata2ri#troubleshooting
If you have any ideas how to make it more helpful, I’d be happy about that PR.
I think the rpy2 project would be happy to accept a PR for the R version requirement, as it is the one requiring it. I just require a working rpy2 version, however that comes to be.
I’m sure rpy2 could be fixed to not use that specific function (and possible other 3.6+ features) if you ask/try!