Closed Richard0146 closed 2 years ago
zellkonverter itself uses its own Conda environment to manage the various Python packages. So I'm guessing that your Conda is fighting with zellkonverter's Conda, leading to the conda-related warnings (and ultimately the error).
You could try telling it to use your Conda instead of installing its own. This is done by setting export BASILISK_EXTERNAL_CONDA=/home/labw/anaconda3
somewhere, usually in your ~/.Renviron
, reinstalling basilisk and zellkonverter, and hoping for the best. This functionality is not particularly well-tested so YMMV.
Unfortunately, I still get the same error after I adjust BASILISK_EXTERNAL_CONDA=/home/labw/anaconda3
.
This error seems to have two parts. firstly,
sh: 4: /home/labw/anaconda3/envs/py38/etc/conda/deactivate.d/deactivate-r-base.sh: [[: not found
sh: 5: /home/labw/anaconda3/envs/py38/etc/conda/deactivate.d/deactivate-gxx_linux-64.sh: Syntax error: "(" unexpected
this seems like an error in executing the conda-related commands in the server environment, but the fatal error is like the following socketAccept error
Error in socketAccept(soc, blocking = TRUE, open = "a+b") :
cannot open the connection
I updated Basilisk with reference to the solution in Issue #36 but still haven't solved it. Warnings and Errors are very similar to issue #36
>Sys.getenv()
BASILISK_EXTERNAL_CONDA
/home/labw/anaconda3
>library(basilisk.utils)
>getCondaDir(installed = TRUE)
[1] "/home/labw/anaconda3"
The first failure causes the second, so that's not surprising.
I forgot to mention that, as part of the reinstallation, you should also delete the directory at basilisk.utils::getExternalDir()
. That contains the environment generated by basilisk's conda; you want to make sure that the environment is instead generated by your system conda. Whether this makes a difference or not is anyone's guess, but one would hope that two environments generated by the same conda instance are at least compatible with each other.
If that doesn't work... ¯\_(ツ)_/¯. The first failing command is run on the command line, and looks like:
. '/home/luna/.cache/basilisk/1.3.7/0/etc/profile.d/conda.sh' && conda activate && /home/luna/Software/R/trunk/bin/Rscript --no-save --no-restore --no-site-file --no-init-file --default-packages=NULL -e "con <- socketConnection(port=11886, open='wb', blocking=TRUE);serialize(Sys.getenv(), con);close(con)"
You can find the equivalent command for your systemby running debug(basilisk.utils:::.activate_condaenv)
, calling any basilisk-powered function like writeH5AD()
, stepping through the function line by line, and then printing out the value of act.cmd
when you get to the line where it is defined. Once you get that command, it would be instructive to see what happens when you try to run it outside of R, just to make sure that it's not an error with the R set-up itself.
@Richard0146 Were you able to make any progress with this?
I got results like following:
debug: system(paste(act.cmd, collapse = " "), intern = TRUE)
Browse[3]>
sh: 4: /home/labw/anaconda3/envs/py38/etc/conda/deactivate.d/deactivate-r-base.sh: [[: not found
sh: 5: /home/labw/anaconda3/envs/py38/etc/conda/deactivate.d/deactivate-gxx_linux-64.sh: Syntax error: "(" unexpected
debug: listener <- socketAccept(soc, blocking = TRUE, open = "a+b")
Warning message:
In system(paste(act.cmd, collapse = " "), intern = TRUE) :
running command '. '/home/labw/anaconda3/etc/profile.d/conda.sh' && conda activate && /home/labw/anaconda3/envs/py38/lib/R/bin/Rscript --default-packages=NULL -e "con <- socketConnection(port=11640, open='wb', blocking=TRUE);serialize(Sys.getenv(), con);close(con)"' had status 2
Browse[3]> print(act.cmd)
[1] "."
[2] "'/home/labw/anaconda3/etc/profile.d/conda.sh'"
[3] "&&"
[4] "conda"
[5] "activate"
[6] "&&"
[7] "/home/labw/anaconda3/envs/py38/lib/R/bin/Rscript"
[8] "--default-packages=NULL"
[9] "-e"
[10] "\"con <- socketConnection(port=11640, open='wb', blocking=TRUE);serialize(Sys.getenv(), con);close(con)\""
I have no idea what need to do next.
When I run the code outside, it shows
(py38) labw@labw-GPU:~$ . '/home/labw/anaconda3/etc/profile.d/conda.sh'
(py38) labw@labw-GPU:~$ conda activate
(base) labw@labw-GPU:~$ /home/labw/anaconda3/envs/py38/lib/R/bin/Rscript --default-packages=NULL -e "con <- socketConnection(port=11566, open='wb', blocking=TRUE);serialize(Sys.getenv(), con);close(con)"
Error in socketConnection(port = 11566, open = "wb", blocking = TRUE) :
cannot open the connection
In addition: Warning message:
In socketConnection(port = 11566, open = "wb", blocking = TRUE) :
localhost:11566 cannot be opened
Execution halted
I tried to change the original code in basilisk to remove conda activate
, and the top two lines that sh4
and sh5
was disappeared, however there is still socket problem:
Browse[2]>
debug: listener <- socketAccept(soc, blocking = TRUE, open = "a+b")
Browse[2]>
Error in socketAccept(soc, blocking = TRUE, open = "a+b") :
cannot open the connection
In addition: Warning message:
In socketAccept(soc, blocking = TRUE, open = "a+b") :
problem in accepting connections on this socket
> writeH5AD(sce,'test.h5ad')
Error in socketAccept(soc, blocking = TRUE, open = "a+b") :
cannot open the connection
In addition: Warning message:
In socketAccept(soc, blocking = TRUE, open = "a+b") :
problem in accepting connections on this socket
>print(act.cmd)
[1] "."
[2] "'/home/labw/anaconda3/etc/profile.d/conda.sh'"
[3] "/home/labw/anaconda3/envs/py38/lib/R/bin/Rscript"
[4] "--default-packages=NULL"
[5] "-e"
[6] "\"con <- socketConnection(port=11150, open='wb', blocking=TRUE);serialize(Sys.getenv(), con);close(con)\""
After scratching my head for some time, I just skipped the failing activation in basilisk.utils (1.3.9). So it'll just give a warning and try to keep going. Maybe this will allow you to proceed with the rest of the function, I'm not sure; the failing activation may be a symptom of other problems in the environment that precludes the correct use of conda/reticulate.
@lazappi we should make #46 (and the corresponding writer) a priority to get it in the next release.
I'm not sure what I should do now.... Should I skip listener <-
line in debug mode?
For the time being, you can try to install basilisk.utils from GitHub:
devtools::install_github("basilisk.utils")
devtools::install_github("basilisk")
This also necessitates an install of the development version of basilisk, because those two are tied together.
In this development version, the problematic activation step is just skipped if it fails, allowing you to continue on with the rest of the function. This... may or may not work, if the underlying issue also affects the rest of reticulate's behavior.
But you might as well give it a shot, because I'm out of ideas about how why it fails on your system.
I'm going to close this because it seems to be somewhat system specific and I'm hoping has been fixed in more recent release. Please comment/reopen if needed.
Hi, when I running
writeH5AD
for storing sce object in ubuntu system, it reported socketAccept errorfor SessionInfo:
I run the R under conda (Python 3.8.8) environment. For my windows system, same sce object can be stored by
writeH5AD
successfully without any errors. Can you help me to see what the problem is? Is it a linux system problem or a conda environment problem? Thank you.