dynverse / anndata

Annotated multivariate observation data in R
https://anndata.dynverse.org
Other
43 stars 4 forks source link

"Unable to open file, file not found" despite the file is actually there in the right place #18

Closed akhst7 closed 2 years ago

akhst7 commented 2 years ago

Hi,

I first run following Iines to setup python env;

>library(reticulate)
>use_condaenv("velocity")
> py_config()
python:         /opt/homebrew/Caskroom/miniforge/base/envs/velocity/bin/python3
libpython:      /opt/homebrew/Caskroom/miniforge/base/envs/velocity/lib/libpython3.10.dylib
pythonhome:     /opt/homebrew/Caskroom/miniforge/base/envs/velocity:/opt/homebrew/Caskroom/miniforge/base/envs/velocity
version:        3.10.2 | packaged by conda-forge | (main, Feb  1 2022, 19:29:01) [Clang 11.1.0 ]
numpy:          /opt/homebrew/Caskroom/miniforge/base/envs/velocity/lib/python3.10/site-packages/numpy
numpy_version:  1.21.5

Then, I run anndata as follows;

library(anndata) adata<-read_h5ad("~/Desktop/adata.h5ad")

and I get a following error message;

Error in py_call_impl(callable, dots$args, dots$keywords) : 
FileNotFoundError: [Errno 2] Unable to open file (unable to open file: name = '~/OneDrive - Indiana University/Velocity/FTAP_velocity/counts_filtered/adata.h5ad', errno = 2, error message = 'No such file or directory', flags = 0, o_flags = 0)
10.
stop(structure(list(message = "FileNotFoundError: [Errno 2] Unable to open file (unable to open file: name = '~/OneDrive - Indiana University/Velocity/FTAP_velocity/counts_filtered/adata.h5ad', errno = 2, error message = 'No such file or directory', flags = 0, o_flags = 0)\n", 
call = py_call_impl(callable, dots$args, dots$keywords), 
cppstack = structure(list(file = "", line = -1L, stack = c("1 reticulate.so 0x0000000113f3a048 _ZN4Rcpp9exceptionC2EPKcb + 176", 
"2 reticulate.so 0x0000000113f548f0 _ZN4Rcpp4stopERKNSt3__112basic_stringIcNS0_11char_traitsIcEENS0_9allocatorIcEEEE + 52", ...
9.
h5py at h5f.pyx#106
8.
h5py at _objects.pyx#55
7.
h5py at _objects.pyx#54
6.
make_fid at files.py#220
5.
__init__ at files.py#507
4.
read_h5ad at h5ad.py#224
3.
python_anndata$read_h5ad(filename = filename, backed = backed)
2.
py_to_r_ifneedbe(python_anndata$read_h5ad(filename = filename, 
backed = backed))
1.
read_h5ad("~/OneDrive - Indiana University/Velocity/FTAP_velocity/counts_filtered/adata.h5ad")

This happens regardless of file location.

Any workaround for this ?

Thanks.

> sessionInfo()
R version 4.1.2 (2021-11-01)
Platform: aarch64-apple-darwin20 (64-bit)
Running under: macOS Monterey 12.3.1

Matrix products: default
LAPACK: /Library/Frameworks/R.framework/Versions/4.1-arm64/Resources/lib/libRlapack.dylib

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] anndata_0.7.5.3      reticulate_1.24-9000 sp_1.4-7             SeuratObject_4.1.0  

loaded via a namespace (and not attached):
 [1] progressr_0.10.0   Rcpp_1.0.8.3       lattice_0.20-45    codetools_0.2-18   listenv_0.8.0      future_1.25.0     
 [7] png_0.1-7          assertthat_0.2.1   digest_0.6.29      parallelly_1.31.1  R6_2.5.1           grid_4.1.2        
[13] jsonlite_1.8.0     cli_3.3.0          rlang_1.0.2        future.apply_1.9.0 Matrix_1.4-1       tools_4.1.2       
[19] parallel_4.1.2     compiler_4.1.2     rgeos_0.5-9        globals_0.14.0 
neofetch                                                                            09:09:11 PM
                    'c.          akihikohoji@Akihikos-Mac-mini.local
                 ,xNMM.          -----------------------------------
               .OMMMMo           OS: macOS 12.3.1 21E258 arm64
               OMMM0,            Host: Macmini9,1
     .;loddo:' loolloddol;.      Kernel: 21.4.0
   cKMMMMMMMMMMNWMMMMMMMMMM0:    Uptime: 1 day, 22 hours, 40 mins
 .KMMMMMMMMMMMMMMMMMMMMMMMWd.    Packages: 130 (brew)
 XMMMMMMMMMMMMMMMMMMMMMMMX.      Shell: zsh 5.8
;MMMMMMMMMMMMMMMMMMMMMMMM:       Resolution: 1920x1080
:MMMMMMMMMMMMMMMMMMMMMMMM:       DE: Aqua
.MMMMMMMMMMMMMMMMMMMMMMMMX.      WM: Quartz Compositor
 kMMMMMMMMMMMMMMMMMMMMMMMMWd.    WM Theme: Blue (Light)
 .XMMMMMMMMMMMMMMMMMMMMMMMMMMk   Terminal: iTerm2
  .XMMMMMMMMMMMMMMMMMMMMMMMMK.   Terminal Font: MesloLGS-NF-Regular 12
    kMMMMMMMMMMMMMMMMMMMMMMd     CPU: Apple M1
     ;KMMMMMMMWXXWMMMMMMMk.      GPU: Apple M1
       .cooc,.    .,coo:.        Memory: 2133MiB / 16384MiB
rcannood commented 2 years ago

Hey @akhst7 !

Python anndata doesn't recognize the '~' character. If you use the full path, it should recognise it. Maybe I should do some substitution on the file path so it behaves more like what R users are used to.

Does this solve your problem?

Robrecht

rcannood commented 2 years ago

I quickly added some path normalisation. Can you install the development version of anndata to see if this resolves your issue? → remotes::install_github("dynverse/anndata@main")

akhst7 commented 2 years ago

@rcannood,

The new developmental version fixed the issue. A full path to the file still works but '~" worked in the previous version of reticulate and anndata. Weird.

Anyway, Thanks for a quick fix.