bodkan / slendr

Population genetic simulations in R 🌍
https://bodkan.net/slendr
Other
54 stars 5 forks source link

no attribute 'get_pedigree_ids' #150

Closed willright28 closed 8 months ago

willright28 commented 8 months ago

Hi @bodkan ,

A small question, running slim get error message:"Error in py_get_attr_impl(x, name, silent) : AttributeError: module 'main' has no attribute 'get_pedigree_ids'".

check_env looks all right: slendr requirements:

Thanks for your time!

bodkan commented 8 months ago

Hi, can you please open a fresh terminal, start R there, type in (in sequence):

library(slendr)

Then

init_env()

And then

check_env()

And paste all the contents that you get from each of those commands one after another?

bodkan commented 8 months ago

Also, I'm not sure what "running slim" means here. It's important for me to know where are you running it (RStudio, R, operating system, version of R -- you can get that from Sys.info()), what version of slendr (get that from help(package = "slendr") and running what -- without having a minimum necessary slendr R script which still gets you error, I have nothing to work with, I'm afraid.

This is a great guide on what I'm asking that applies to submitting R bugs regardless of the package: http://adv-r.had.co.nz/Reproducibility.html

Thanks!

willright28 commented 8 months ago

Thanks for your attention! I will try my best to present the question as clearly as possible.

I run slendr v 0.8.1.9000 by R on centos 7. Sys.info() returns:

> Sys.info()
                              sysname                               release
                              "Linux"        "3.10.0-1160.102.1.el7.x86_64"
                              version                              nodename
"#1 SMP Tue Oct 17 15:42:21 UTC 2023"               "localhost.localdomain"
                              machine                                 login
                             "x86_64"                                "song"
                                 user                        effective_user
                               "song"                                "song"

The content is too long, to be short, library(slendr) worked fine but init_env() reported an error message: "No module named 'numpy'" and all requirements could not be deteced this time by check_env().

> library(slendr)
> init_env()
Error in py_run_file_impl(file, local, convert) :
  ModuleNotFoundError: No module named 'numpy'
Run `reticulate::py_last_error()` for details.
> check_env()

# >>>>>>>>>>>>>>>>>>>>>> ERROR REPORT <<<<<<<<<<<<<<<<<<<<<<

    Traceback (most recent call last):
      File "/home/sparrow/.local/share/r-miniconda/lib/python3.11/site-packages/                                                                                                                                                             conda/exception_handler.py", line 17, in __call__
        return func(*args, **kwargs)
               ^^^^^^^^^^^^^^^^^^^^^
      File "/home/sparrow/.local/share/r-miniconda/lib/python3.11/site-packages/                                                                                                                                                             conda/cli/main.py", line 110, in main_sourced
        print(activator.execute(), end="")
              ^^^^^^^^^^^^^^^^^^^
      File "/home/sparrow/.local/share/r-miniconda/lib/python3.11/site-packages/                                                                                                                                                             conda/activate.py", line 203, in execute
        return getattr(self, self.command)()
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/home/sparrow/.local/share/r-miniconda/lib/python3.11/site-packages/                                                                                                                                                             conda/activate.py", line 168, in activate
        builder_result = self.build_activate(self.env_name_or_prefix)
                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/home/sparrow/.local/share/r-miniconda/lib/python3.11/site-packages/                                                                                                                                                             conda/activate.py", line 347, in build_activate
        return self._build_activate_stack(env_name_or_prefix, False)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/home/sparrow/.local/share/r-miniconda/lib/python3.11/site-packages/                                                                                                                                                             conda/activate.py", line 426, in _build_activate_stack
        self._replace_prefix_in_path(old_conda_prefix, prefix)
      File "/home/sparrow/.local/share/r-miniconda/lib/python3.11/site-packages/                                                                                                                                                             conda/activate.py", line 681, in _replace_prefix_in_path
        if path_list[last_idx + 1] == library_bin_dir:
           ~~~~~~~~~^^^^^^^^^^^^^^
    IndexError: list index out of range

`$ /home/sparrow/.local/share/r-miniconda/bin/conda shell.posix activate`

  environment variables:
                 CIO_TEST=<not set>
                CLASSPATH=/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.345.b01-
                          1.el7_9.x86_64//lib/tools.jar:/usr/lib/jvm/java-1.8.0-                                                                                                                                                             openjdk-
                          1.8.0.345.b01-1.el7_9.x86_64//lib/dt.jar:/usr/lib/jvm/                                                                                                                                                             java-1.8.0-
                          openjdk-1.8.0.345.b01-1.el7_9.x86_64//lib
        CMAKE_PREFIX_PATH=/home/sparrow/.conda/envs/rgdal:/home/sparrow/.conda/e                                                                                                                                                             nvs/rgdal/x86_64
                          -conda-linux-gnu/sysroot/usr
      CONDA_BUILD_SYSROOT=/home/sparrow/.conda/envs/rgdal/x86_64-conda-linux-gnu                                                                                                                                                             /sysroot
        CONDA_DEFAULT_ENV=rgdal
                CONDA_EXE=/home/sparrow/.local/share/r-miniconda/bin/conda
             CONDA_PREFIX=/home/sparrow/.conda/envs/rgdal
           CONDA_PREFIX_1=/home/share/Anaconda/Anaconda_install
    CONDA_PROMPT_MODIFIER=(rgdal)
         CONDA_PYTHON_EXE=/home/sparrow/.local/share/r-miniconda/bin/python
               CONDA_ROOT=/home/sparrow/.local/share/r-miniconda
              CONDA_SHLVL=2
    CONDA_TOOLCHAIN_BUILD=x86_64-conda-linux-gnu
     CONDA_TOOLCHAIN_HOST=x86_64-conda-linux-gnu
           CURL_CA_BUNDLE=<not set>
           C_INCLUDE_PATH=/usr/include
         GDAL_DRIVER_PATH=/home/sparrow/.conda/envs/rgdal/lib/gdalplugins
     JAVA_LD_LIBRARY_PATH=/home/sparrow/.conda/envs/rgdal/jre/lib/amd64/server
          LD_LIBRARY_PATH=/home/sparrow/.conda/envs/new/jre/lib/amd64/server/:/h                                                                                                                                                             ome/sparrow/.con
                          da/envs/new/jre/lib/amd64/server
               LD_PRELOAD=<not set>
                     PATH=/home/sparrow/.local/share/r-
                          miniconda/condabin:/home/sparrow/.local/share/r-
                          miniconda/bin:/home/sparrow/.local/share/r-
                          miniconda/condabin:/home/sparrow/.local/share/r-minico                                                                                                                                                             nda/envs/Python-
                          3.11_msprime-1.2.0_tskit-0.5.6_pyslim-1.0.4_tspop-
                          0.0.2/bin:/home/sparrow/.local/share/r-
                          miniconda/condabin:/home/sparrow/.local/share/r-
                          miniconda/bin:/home/sparrow/.local/share/r-
                          miniconda/condabin:/home/sparrow/.local/share/r-
                          miniconda/bin:/home/sparrow/.jenv/shims:/home/sparrow/                                                                                                                                                             .jenv/bin:/home/
                          sparrow/.aspera/connect/bin:/home/sparrow/.local/share                                                                                                                                                             /r-
                          miniconda/bin:/home/share/Anaconda/Anaconda_install/co                                                                                                                                                             ndabin:/disk3/hk
                          qm/badmixture/code:/disk3/hkqm/volcanofinder/SF2:/disk                                                                                                                                                             3/hkqm/volcanofi
                          nder/volcanofinder_v1.0:/disk3/hkqm/baypass/baypass_pu                                                                                                                                                             blic-master/sour
                          ces:/home/xueboning/software/paml4.9j/bin:/home/xuebon                                                                                                                                                             ing/software/Par
                          aAT2.0:/home/xueboning/software/KaKs_Calculator2.0/src                                                                                                                                                             :/home/sparrow/s
                          oftware/Dsuite/Build:/home/zhangshuai/download:/home/s                                                                                                                                                             hare/EMBOSS-
                          6.6.0/ajax/pcre:/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.                                                                                                                                                             345.b01-
                          1.el7_9.x86_64/bin:/usr/java/jre1.8.0_151/bin:/usr/jav                                                                                                                                                             a/jre1.8.0_151/b
                          in:/opt/tsce4/maui/sbin:/opt/tsce4/maui/bin:/opt/tsce4                                                                                                                                                             /torque6/bin:/op
                          t/tsce4/torque6/sbin:/home/share/rmblast-
                          2.10.0/bin:/home/share/bedtools:/home/share/AdmixTools                                                                                                                                                             /bin:/home/share
                          /beast/bin:/home/share/Anaconda/Anaconda_install/bin:/                                                                                                                                                             home/sparrow/.as
                          pera/connect/bin:/home/sparrow/software/bedops/bin:/ho                                                                                                                                                             me/share/delly/s
                          rc:/home/share/ncbi-blast-
                          2.12.0+/bin:/home/share/lastz/src:/home/share/bowtie2-                                                                                                                                                             2.4.4-linux-
                          x86_64:/home/share/paup:/var/lib/snapd/snap/dmd/102/bi                                                                                                                                                             n:/home/sparrow/
                          software/msmc2-2.1.3/build/release:/home/cyl_temp/soft                                                                                                                                                             ware/sambada-
                          0.8.3-ubuntu/binaries:/home/share/proj-
                          8.1.0/build/bin:/disk2/prunella/software/discoal:/usr/                                                                                                                                                             local/bin:/usr/l
                          ocal/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/var/lib/s                                                                                                                                                             napd/snap/bin:/h
                          ome/sparrow:/home/share/bcftools-1.9:/home/share/bwa-
                          0.7.17:/home/share/samtools-1.9:/home/share/gatk-
                          4.1.8.1:/home/share/plink_1.9:/home/share/plink_2.0:/h                                                                                                                                                             ome/share/vcftoo
                          ls_0.1.13/bin:/home/zhangshuai/bin/sratoolkit.3.0.0-
                          centos_linux64/bin:/home/caoqiansheng/.aspera/connect/                                                                                                                                                             bin:/home/sparro
                          w/.local/bin:/home/sparrow/bin:/home/sparrow/.conda/en                                                                                                                                                             vs/rgdal/bin/x86
                          _64-conda-linux-gnu-c++:/home/sparrow/.conda/envs/rgda                                                                                                                                                             l/bin
               PYTHONPATH=:/home/sparrow/software/kobas-3.0/src
           QT_PLUGIN_PATH=/usr/lib64/kde4/plugins:/usr/lib/kde4/plugins
       REQUESTS_CA_BUNDLE=<not set>
            SSL_CERT_FILE=<not set>
        UDUNITS2_XML_PATH=/home/sparrow/.conda/envs/rgdal/share/udunits/udunits2                                                                                                                                                             .xml

     active environment : rgdal
    active env location : /home/sparrow/.conda/envs/rgdal
            shell level : 2
       user config file : /home/sparrow/.condarc
 populated config files : /home/sparrow/.condarc
          conda version : 23.11.0
    conda-build version : not installed
         python version : 3.11.5.final.0
                 solver : libmamba (default)
       virtual packages : __archspec=1=cascadelake
                          __conda=23.11.0=0
                          __glibc=2.17=0
                          __linux=3.10.0=0
                          __unix=0=0
       base environment : /home/sparrow/.local/share/r-miniconda  (writable)
      conda av data dir : /home/sparrow/.local/share/r-miniconda/etc/conda
  conda av metadata url : None
           channel URLs : https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/bi                                                                                                                                                             oconda/linux-64
                          https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/bi                                                                                                                                                             oconda/noarch
                          https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/co                                                                                                                                                             nda-forge/linux-64
                          https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/co                                                                                                                                                             nda-forge/noarch
                          https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/mai                                                                                                                                                             n/linux-64
                          https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/mai                                                                                                                                                             n/noarch
                          https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/fre                                                                                                                                                             e/linux-64
                          https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/fre                                                                                                                                                             e/noarch
          package cache : /home/sparrow/.local/share/r-miniconda/pkgs
                          /home/sparrow/.conda/pkgs
       envs directories : /home/sparrow/.local/share/r-miniconda/envs
                          /home/sparrow/.conda/envs
               platform : linux-64
             user-agent : conda/23.11.0 requests/2.31.0 CPython/3.11.5 Linux/3.1                                                                                                                                                             0.0-1160.11.1.el7.x86_64 centos/7.9.2009 glibc/2.17 solver/libmamba conda-libmam                                                                                                                                                             ba-solver/23.12.0 libmambapy/1.5.3
                UID:GID : 1000:1000
             netrc file : None
           offline mode : False

An unexpected error has occurred. Conda has prepared the above report.
If you suspect this error is being caused by a malfunctioning plugin,
consider using the --no-plugins option to turn off plugins.

Example: conda --no-plugins install <package>

Alternatively, you can set the CONDA_NO_PLUGINS environment variable on
the command line to run the command without plugins enabled.

Example: CONDA_NO_PLUGINS=true conda install <package>

Timeout reached. No report sent.

# >>>>>>>>>>>>>>>>>>>>>> ERROR REPORT <<<<<<<<<<<<<<<<<<<<<<

    Traceback (most recent call last):
      File "/home/sparrow/.local/share/r-miniconda/lib/python3.11/site-packages/                                                                                                                                                             conda/exception_handler.py", line 17, in __call__
        return func(*args, **kwargs)
               ^^^^^^^^^^^^^^^^^^^^^
      File "/home/sparrow/.local/share/r-miniconda/lib/python3.11/site-packages/                                                                                                                                                             conda/cli/main.py", line 110, in main_sourced
        print(activator.execute(), end="")
              ^^^^^^^^^^^^^^^^^^^
      File "/home/sparrow/.local/share/r-miniconda/lib/python3.11/site-packages/                                                                                                                                                             conda/activate.py", line 203, in execute
        return getattr(self, self.command)()
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/home/sparrow/.local/share/r-miniconda/lib/python3.11/site-packages/                                                                                                                                                             conda/activate.py", line 168, in activate
        builder_result = self.build_activate(self.env_name_or_prefix)
                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/home/sparrow/.local/share/r-miniconda/lib/python3.11/site-packages/                                                                                                                                                             conda/activate.py", line 347, in build_activate
        return self._build_activate_stack(env_name_or_prefix, False)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/home/sparrow/.local/share/r-miniconda/lib/python3.11/site-packages/                                                                                                                                                             conda/activate.py", line 426, in _build_activate_stack
        self._replace_prefix_in_path(old_conda_prefix, prefix)
      File "/home/sparrow/.local/share/r-miniconda/lib/python3.11/site-packages/                                                                                                                                                             conda/activate.py", line 681, in _replace_prefix_in_path
        if path_list[last_idx + 1] == library_bin_dir:
           ~~~~~~~~~^^^^^^^^^^^^^^
    IndexError: list index out of range

`$ /home/sparrow/.local/share/r-miniconda/bin/conda shell.posix activate /home/s                                                                                                                                                             parrow/.local/share/r-miniconda/envs/Python-3.11_msprime-1.2.0_tskit-0.5.6_pysli                                                                                                                                                             m-1.0.4_tspop-0.0.2`

  environment variables:
                 CIO_TEST=<not set>
                CLASSPATH=/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.345.b01-
                          1.el7_9.x86_64//lib/tools.jar:/usr/lib/jvm/java-1.8.0-                                                                                                                                                             openjdk-
                          1.8.0.345.b01-1.el7_9.x86_64//lib/dt.jar:/usr/lib/jvm/                                                                                                                                                             java-1.8.0-
                          openjdk-1.8.0.345.b01-1.el7_9.x86_64//lib
        CMAKE_PREFIX_PATH=/home/sparrow/.conda/envs/rgdal:/home/sparrow/.conda/e                                                                                                                                                             nvs/rgdal/x86_64
                          -conda-linux-gnu/sysroot/usr
      CONDA_BUILD_SYSROOT=/home/sparrow/.conda/envs/rgdal/x86_64-conda-linux-gnu                                                                                                                                                             /sysroot
        CONDA_DEFAULT_ENV=rgdal
                CONDA_EXE=/home/sparrow/.local/share/r-miniconda/bin/conda
             CONDA_PREFIX=/home/sparrow/.conda/envs/rgdal
           CONDA_PREFIX_1=/home/share/Anaconda/Anaconda_install
    CONDA_PROMPT_MODIFIER=(rgdal)
         CONDA_PYTHON_EXE=/home/sparrow/.local/share/r-miniconda/bin/python
               CONDA_ROOT=/home/sparrow/.local/share/r-miniconda
              CONDA_SHLVL=2
    CONDA_TOOLCHAIN_BUILD=x86_64-conda-linux-gnu
     CONDA_TOOLCHAIN_HOST=x86_64-conda-linux-gnu
           CURL_CA_BUNDLE=<not set>
           C_INCLUDE_PATH=/usr/include
         GDAL_DRIVER_PATH=/home/sparrow/.conda/envs/rgdal/lib/gdalplugins
     JAVA_LD_LIBRARY_PATH=/home/sparrow/.conda/envs/rgdal/jre/lib/amd64/server
          LD_LIBRARY_PATH=/home/sparrow/.conda/envs/new/jre/lib/amd64/server/:/h                                                                                                                                                             ome/sparrow/.con
                          da/envs/new/jre/lib/amd64/server
               LD_PRELOAD=<not set>
                     PATH=/home/sparrow/.local/share/r-
                          miniconda/condabin:/home/sparrow/.local/share/r-
                          miniconda/bin:/home/sparrow/.local/share/r-
                          miniconda/condabin:/home/sparrow/.local/share/r-minico                                                                                                                                                             nda/envs/Python-
                          3.11_msprime-1.2.0_tskit-0.5.6_pyslim-1.0.4_tspop-
                          0.0.2/bin:/home/sparrow/.local/share/r-
                          miniconda/condabin:/home/sparrow/.local/share/r-
                          miniconda/bin:/home/sparrow/.local/share/r-
                          miniconda/condabin:/home/sparrow/.local/share/r-
                          miniconda/bin:/home/sparrow/.jenv/shims:/home/sparrow/                                                                                                                                                             .jenv/bin:/home/
                          sparrow/.aspera/connect/bin:/home/sparrow/.local/share                                                                                                                                                             /r-
                          miniconda/bin:/home/share/Anaconda/Anaconda_install/co                                                                                                                                                             ndabin:/disk3/hk
                          qm/badmixture/code:/disk3/hkqm/volcanofinder/SF2:/disk                                                                                                                                                             3/hkqm/volcanofi
                          nder/volcanofinder_v1.0:/disk3/hkqm/baypass/baypass_pu                                                                                                                                                             blic-master/sour
                          ces:/home/xueboning/software/paml4.9j/bin:/home/xuebon                                                                                                                                                             ing/software/Par
                          aAT2.0:/home/xueboning/software/KaKs_Calculator2.0/src                                                                                                                                                             :/home/sparrow/s
                          oftware/Dsuite/Build:/home/zhangshuai/download:/home/s                                                                                                                                                             hare/EMBOSS-
                          6.6.0/ajax/pcre:/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.                                                                                                                                                             345.b01-
                          1.el7_9.x86_64/bin:/usr/java/jre1.8.0_151/bin:/usr/jav                                                                                                                                                             a/jre1.8.0_151/b
                          in:/opt/tsce4/maui/sbin:/opt/tsce4/maui/bin:/opt/tsce4                                                                                                                                                             /torque6/bin:/op
                          t/tsce4/torque6/sbin:/home/share/rmblast-
                          2.10.0/bin:/home/share/bedtools:/home/share/AdmixTools                                                                                                                                                             /bin:/home/share
                          /beast/bin:/home/share/Anaconda/Anaconda_install/bin:/                                                                                                                                                             home/sparrow/.as
                          pera/connect/bin:/home/sparrow/software/bedops/bin:/ho                                                                                                                                                             me/share/delly/s
                          rc:/home/share/ncbi-blast-
                          2.12.0+/bin:/home/share/lastz/src:/home/share/bowtie2-                                                                                                                                                             2.4.4-linux-
                          x86_64:/home/share/paup:/var/lib/snapd/snap/dmd/102/bi                                                                                                                                                             n:/home/sparrow/
                          software/msmc2-2.1.3/build/release:/home/cyl_temp/soft                                                                                                                                                             ware/sambada-
                          0.8.3-ubuntu/binaries:/home/share/proj-
                          8.1.0/build/bin:/disk2/prunella/software/discoal:/usr/                                                                                                                                                             local/bin:/usr/l
                          ocal/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/var/lib/s                                                                                                                                                             napd/snap/bin:/h
                          ome/sparrow:/home/share/bcftools-1.9:/home/share/bwa-
                          0.7.17:/home/share/samtools-1.9:/home/share/gatk-
                          4.1.8.1:/home/share/plink_1.9:/home/share/plink_2.0:/h                                                                                                                                                             ome/share/vcftoo
                          ls_0.1.13/bin:/home/zhangshuai/bin/sratoolkit.3.0.0-
                          centos_linux64/bin:/home/caoqiansheng/.aspera/connect/                                                                                                                                                             bin:/home/sparro
                          w/.local/bin:/home/sparrow/bin:/home/sparrow/.conda/en                                                                                                                                                             vs/rgdal/bin/x86
                          _64-conda-linux-gnu-c++:/home/sparrow/.conda/envs/rgda                                                                                                                                                             l/bin
               PYTHONPATH=:/home/sparrow/software/kobas-3.0/src
           QT_PLUGIN_PATH=/usr/lib64/kde4/plugins:/usr/lib/kde4/plugins
       REQUESTS_CA_BUNDLE=<not set>
            SSL_CERT_FILE=<not set>
        UDUNITS2_XML_PATH=/home/sparrow/.conda/envs/rgdal/share/udunits/udunits2                                                                                                                                                             .xml

     active environment : rgdal
    active env location : /home/sparrow/.conda/envs/rgdal
            shell level : 2
       user config file : /home/sparrow/.condarc
 populated config files : /home/sparrow/.condarc
          conda version : 23.11.0
    conda-build version : not installed
         python version : 3.11.5.final.0
                 solver : libmamba (default)
       virtual packages : __archspec=1=cascadelake
                          __conda=23.11.0=0
                          __glibc=2.17=0
                          __linux=3.10.0=0
                          __unix=0=0
       base environment : /home/sparrow/.local/share/r-miniconda  (writable)
      conda av data dir : /home/sparrow/.local/share/r-miniconda/etc/conda
  conda av metadata url : None
           channel URLs : https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/bi                                                                                                                                                             oconda/linux-64
                          https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/bi                                                                                                                                                             oconda/noarch
                          https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/co                                                                                                                                                             nda-forge/linux-64
                          https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/co                                                                                                                                                             nda-forge/noarch
                          https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/mai                                                                                                                                                             n/linux-64
                          https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/mai                                                                                                                                                             n/noarch
                          https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/fre                                                                                                                                                             e/linux-64
                          https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/fre                                                                                                                                                             e/noarch
          package cache : /home/sparrow/.local/share/r-miniconda/pkgs
                          /home/sparrow/.conda/pkgs
       envs directories : /home/sparrow/.local/share/r-miniconda/envs
                          /home/sparrow/.conda/envs
               platform : linux-64
             user-agent : conda/23.11.0 requests/2.31.0 CPython/3.11.5 Linux/3.1                                                                                                                                                             0.0-1160.11.1.el7.x86_64 centos/7.9.2009 glibc/2.17 solver/libmamba conda-libmam                                                                                                                                                             ba-solver/23.12.0 libmambapy/1.5.3
                UID:GID : 1000:1000
             netrc file : None
           offline mode : False

An unexpected error has occurred. Conda has prepared the above report.
If you suspect this error is being caused by a malfunctioning plugin,
consider using the --no-plugins option to turn off plugins.

Example: conda --no-plugins install <package>

Alternatively, you can set the CONDA_NO_PLUGINS environment variable on
the command line to run the command without plugins enabled.

Example: CONDA_NO_PLUGINS=true conda install <package>

Timeout reached. No report sent.

Summary of the currently active Python environment:

Python binary: /home/sparrow/.local/share/r-miniconda/envs/Python-3.11_msprime-1.2.0_tskit-0.5.6_pyslim-1.0.4_tspop-0.0.2/bin/python
Python version: 3.11.7 | packaged by conda-forge | (main, Dec 23 2023, 14:43:09) [GCC 12.3.0]

slendr requirements:
 - tskit: MISSING ❌
 - msprime: MISSING ❌
 - pyslim: MISSING ❌
 - tspop: MISSING ❌

Note that due to the technical limitations of embedded Python, if you
want to switch to another Python environment you will need to restart
your R session first.

> setup_env()
A required slendr Python environment is already present. You can activate
it by calling init_env().
willright28 commented 8 months ago

Then I clear the env and reinstall it:

> clear_env()
Are you sure you want to delete the automatically created slendr Python
environment? It is located in:

/home/song/miniconda3/envs/Python-3.11_msprime-1.2.0_tskit-0.5.6_pyslim-1.0.4_tspop-0.0.2/

If you remove it, you can create it again by running`setup_env()`
without any arguments in a new R session.

1: No
2: Yes

Selection: 2
+ /home/song/miniconda3/bin/conda 'remove' '--yes' '--name' 'Python-3.11_msprime-1.2.0_tskit-0.5.6_pyslim-1.0.4_tspop-0.0.2' '--all'

Remove all packages in environment /home/song/miniconda3/envs/Python-3.11_msprime-1.2.0_tskit-0.5.6_pyslim-1.0.4_tspop-0.0.2:

## Package Plan ##

  environment location: /home/song/miniconda3/envs/Python-3.11_msprime-1.2.0_tskit-0.5.6_pyslim-1.0.4_tspop-0.0.2

The following packages will be REMOVED:

  _libgcc_mutex-0.1-conda_forge
  _openmp_mutex-4.5-2_gnu
  bzip2-1.0.8-hd590300_5
  ca-certificates-2023.11.17-hbcca054_0
  ld_impl_linux-64-2.40-h41732ed_0
  libexpat-2.5.0-hcb278e6_1
  libffi-3.4.2-h7f98852_5
  libgcc-ng-13.2.0-h807b86a_3
  libgomp-13.2.0-h807b86a_3
  libnsl-2.0.1-hd590300_0
  libsqlite-3.44.2-h2797004_0
  libuuid-2.38.1-h0b41bf4_0
  libxcrypt-4.4.36-hd590300_1
  libzlib-1.2.13-hd590300_5
  ncurses-6.4-h59595ed_2
  openssl-3.2.0-hd590300_1
  pip-23.3.2-pyhd8ed1ab_0
  python-3.11.7-hab00c5b_1_cpython
  readline-8.2-h8228510_1
  setuptools-69.0.3-pyhd8ed1ab_0
  tk-8.6.13-noxft_h4845f30_101
  tzdata-2023d-h0c530f3_0
  wheel-0.42.0-pyhd8ed1ab_0
  xz-5.2.6-h166bdaf_0

Preparing transaction: done
Verifying transaction: done
Executing transaction: done
The slendr Python environment has been sucessfully removed.

> setup_env()
This function will install a completely isolated Miniconda Python distribution
just for slendr and create an environment with all required Python modules.

Everything will be installed into a completely separate location into an
isolated environment in an R library directory. This won't affect your other
Python installations at all. You can always wipe out the automatically created
environment by running clear_env().

Do you wish to proceed with the automated Python environment setup?

1: No
2: Yes

Selection: 2
=======================================================================
Installing slendr's Python environment. Please wait until
the installation procedure finishes. Do NOT interrupt the
process while the installation is still running.
======================================================================

+ /home/song/miniconda3/bin/conda 'create' '--yes' '--name' 'Python-3.11_msprime                                                                                                                                                             -1.2.0_tskit-0.5.6_pyslim-1.0.4_tspop-0.0.2' 'python=3.11' '--quiet' '-c' 'conda                                                                                                                                                             -forge'
Retrieving notices: ...working... done
Collecting package metadata (current_repodata.json): ...working... done
Solving environment: ...working... done

## Package Plan ##

  environment location: /home/song/miniconda3/envs/Python-3.11_msprime-1.2.0_tsk                                                                                                                                                             it-0.5.6_pyslim-1.0.4_tspop-0.0.2

  added / updated specs:
    - python=3.11

The following NEW packages will be INSTALLED:

  _libgcc_mutex      conda-forge/linux-64::_libgcc_mutex-0.1-conda_forge
  _openmp_mutex      conda-forge/linux-64::_openmp_mutex-4.5-2_gnu
  bzip2              conda-forge/linux-64::bzip2-1.0.8-hd590300_5
  ca-certificates    conda-forge/linux-64::ca-certificates-2023.11.17-hbcca054_0                                                                                                                                                             
  ld_impl_linux-64   conda-forge/linux-64::ld_impl_linux-64-2.40-h41732ed_0
  libexpat           conda-forge/linux-64::libexpat-2.5.0-hcb278e6_1
  libffi             conda-forge/linux-64::libffi-3.4.2-h7f98852_5
  libgcc-ng          conda-forge/linux-64::libgcc-ng-13.2.0-h807b86a_3
  libgomp            conda-forge/linux-64::libgomp-13.2.0-h807b86a_3
  libnsl             conda-forge/linux-64::libnsl-2.0.1-hd590300_0
  libsqlite          conda-forge/linux-64::libsqlite-3.44.2-h2797004_0
  libuuid            conda-forge/linux-64::libuuid-2.38.1-h0b41bf4_0
  libxcrypt          conda-forge/linux-64::libxcrypt-4.4.36-hd590300_1
  libzlib            conda-forge/linux-64::libzlib-1.2.13-hd590300_5
  ncurses            conda-forge/linux-64::ncurses-6.4-h59595ed_2
  openssl            conda-forge/linux-64::openssl-3.2.0-hd590300_1
  pip                conda-forge/noarch::pip-23.3.2-pyhd8ed1ab_0
  python             conda-forge/linux-64::python-3.11.7-hab00c5b_1_cpython
  readline           conda-forge/linux-64::readline-8.2-h8228510_1
  setuptools         conda-forge/noarch::setuptools-69.0.3-pyhd8ed1ab_0
  tk                 conda-forge/linux-64::tk-8.6.13-noxft_h4845f30_101
  tzdata             conda-forge/noarch::tzdata-2023d-h0c530f3_0
  wheel              conda-forge/noarch::wheel-0.42.0-pyhd8ed1ab_0
  xz                 conda-forge/linux-64::xz-5.2.6-h166bdaf_0

Preparing transaction: ...working... done
Verifying transaction: ...working... done
Executing transaction: ...working... done
+ /home/song/miniconda3/bin/conda 'install' '--yes' '--name' 'Python-3.11_msprim                                                                                                                                                             e-1.2.0_tskit-0.5.6_pyslim-1.0.4_tspop-0.0.2' '-c' 'conda-forge' 'msprime==1.2.0                                                                                                                                                             ' 'tskit==0.5.6' 'pyslim==1.0.4'
Collecting package metadata (current_repodata.json): done
Solving environment: unsuccessful initial attempt using frozen solve. Retrying w                                                                                                                                                             ith flexible solve.
Collecting package metadata (repodata.json): done
Solving environment: done

==> WARNING: A newer version of conda exists. <==
  current version: 23.7.4
  latest version: 23.11.0

Please update conda by running

    $ conda update -n base -c conda-forge conda

Or to minimize the number of packages updated during conda update use

     conda install conda=23.11.0

## Package Plan ##

  environment location: /home/song/miniconda3/envs/Python-3.11_msprime-1.2.0_tsk                                                                                                                                                             it-0.5.6_pyslim-1.0.4_tspop-0.0.2

  added / updated specs:
    - msprime==1.2.0
    - pyslim==1.0.4
    - tskit==0.5.6

The following packages will be downloaded:

    package                    |            build
    ---------------------------|-----------------
    humanize-4.9.0             |     pyhd8ed1ab_0          64 KB  conda-forge
    importlib-metadata-7.0.1   |     pyha770c72_0          26 KB  conda-forge
    importlib_metadata-7.0.1   |       hd8ed1ab_0           9 KB  conda-forge
    libblas-3.9.0              |21_linux64_openblas          14 KB  conda-forge
    libcblas-3.9.0             |21_linux64_openblas          14 KB  conda-forge
    liblapack-3.9.0            |21_linux64_openblas          14 KB  conda-forge
    libopenblas-0.3.26         |pthreads_h413a1c8_0         5.3 MB  conda-forge
    msprime-1.2.0              |  py311hf9c4b16_3         434 KB  conda-forge
    numpy-1.26.3               |  py311h64a7726_0         7.8 MB  conda-forge
    python_abi-3.11            |          4_cp311           6 KB  conda-forge
    ------------------------------------------------------------
                                           Total:        13.7 MB

The following NEW packages will be INSTALLED:

  attrs              conda-forge/noarch::attrs-23.2.0-pyh71513ae_0
  demes              conda-forge/noarch::demes-0.2.3-pyhd8ed1ab_0
  gsl                conda-forge/linux-64::gsl-2.7-he838d99_0
  humanize           conda-forge/noarch::humanize-4.9.0-pyhd8ed1ab_0
  importlib-metadata conda-forge/noarch::importlib-metadata-7.0.1-pyha770c72_0
  importlib_metadata conda-forge/noarch::importlib_metadata-7.0.1-hd8ed1ab_0
  importlib_resourc~ conda-forge/noarch::importlib_resources-6.1.1-pyhd8ed1ab_0
  jsonschema         conda-forge/noarch::jsonschema-4.21.1-pyhd8ed1ab_0
  jsonschema-specif~ conda-forge/noarch::jsonschema-specifications-2023.12.1-pyh                                                                                                                                                             d8ed1ab_0
  kastore            conda-forge/linux-64::kastore-0.3.2-py311h1f0f07a_2
  libblas            conda-forge/linux-64::libblas-3.9.0-21_linux64_openblas
  libcblas           conda-forge/linux-64::libcblas-3.9.0-21_linux64_openblas
  libgfortran-ng     conda-forge/linux-64::libgfortran-ng-13.2.0-h69a702a_3
  libgfortran5       conda-forge/linux-64::libgfortran5-13.2.0-ha4646dd_3
  liblapack          conda-forge/linux-64::liblapack-3.9.0-21_linux64_openblas
  libopenblas        conda-forge/linux-64::libopenblas-0.3.26-pthreads_h413a1c8_                                                                                                                                                             0
  libstdcxx-ng       conda-forge/linux-64::libstdcxx-ng-13.2.0-h7e041cc_3
  msprime            conda-forge/linux-64::msprime-1.2.0-py311hf9c4b16_3
  numpy              conda-forge/linux-64::numpy-1.26.3-py311h64a7726_0
  pkgutil-resolve-n~ conda-forge/noarch::pkgutil-resolve-name-1.3.10-pyhd8ed1ab_                                                                                                                                                             1
  pyparsing          conda-forge/noarch::pyparsing-3.1.1-pyhd8ed1ab_0
  pyslim             conda-forge/noarch::pyslim-1.0.4-pyhd8ed1ab_0
  python_abi         conda-forge/linux-64::python_abi-3.11-4_cp311
  referencing        conda-forge/noarch::referencing-0.32.1-pyhd8ed1ab_0
  rpds-py            conda-forge/linux-64::rpds-py-0.17.1-py311h46250e7_0
  ruamel.yaml        conda-forge/linux-64::ruamel.yaml-0.18.5-py311h459d7ec_0
  ruamel.yaml.clib   conda-forge/linux-64::ruamel.yaml.clib-0.2.7-py311h459d7ec_                                                                                                                                                             2
  six                conda-forge/noarch::six-1.16.0-pyh6c4a22f_0
  svgwrite           conda-forge/noarch::svgwrite-1.4.3-pyhd8ed1ab_0
  tskit              conda-forge/linux-64::tskit-0.5.6-py311h1f0f07a_0
  zipp               conda-forge/noarch::zipp-3.17.0-pyhd8ed1ab_0

Downloading and Extracting Packages

Preparing transaction: done
Verifying transaction: done
Executing transaction: done
+ . /home/song/miniconda3/bin/activate
+ conda activate 'Python-3.11_msprime-1.2.0_tskit-0.5.6_pyslim-1.0.4_tspop-0.0.2                                                                                                                                                             '
+ '/home/song/miniconda3/envs/Python-3.11_msprime-1.2.0_tskit-0.5.6_pyslim-1.0.4                                                                                                                                                             _tspop-0.0.2/bin/python' -m pip install --upgrade --no-user 'tspop==0.0.2'
Requirement already satisfied: tspop==0.0.2 in ./.local/lib/python3.11/site-pack                                                                                                                                                             ages (0.0.2)
Requirement already satisfied: tskit>=0.2.3 in ./.local/lib/python3.11/site-pack                                                                                                                                                             ages (from tspop==0.0.2) (0.5.6)
Requirement already satisfied: pandas>=1.2.0 in ./.local/lib/python3.11/site-pac                                                                                                                                                             kages (from tspop==0.0.2) (2.2.0)
Requirement already satisfied: numpy>=1.21.0 in ./miniconda3/envs/Python-3.11_ms                                                                                                                                                             prime-1.2.0_tskit-0.5.6_pyslim-1.0.4_tspop-0.0.2/lib/python3.11/site-packages (f                                                                                                                                                             rom tspop==0.0.2) (1.26.3)
Requirement already satisfied: matplotlib>=3.4.0 in ./.local/lib/python3.11/site                                                                                                                                                             -packages (from tspop==0.0.2) (3.8.2)
Requirement already satisfied: contourpy>=1.0.1 in ./.local/lib/python3.11/site-                                                                                                                                                             packages (from matplotlib>=3.4.0->tspop==0.0.2) (1.2.0)
Requirement already satisfied: cycler>=0.10 in ./.local/lib/python3.11/site-pack                                                                                                                                                             ages (from matplotlib>=3.4.0->tspop==0.0.2) (0.12.1)
Requirement already satisfied: fonttools>=4.22.0 in ./.local/lib/python3.11/site                                                                                                                                                             -packages (from matplotlib>=3.4.0->tspop==0.0.2) (4.47.2)
Requirement already satisfied: kiwisolver>=1.3.1 in ./.local/lib/python3.11/site                                                                                                                                                             -packages (from matplotlib>=3.4.0->tspop==0.0.2) (1.4.5)
Requirement already satisfied: packaging>=20.0 in ./.local/lib/python3.11/site-p                                                                                                                                                             ackages (from matplotlib>=3.4.0->tspop==0.0.2) (23.2)
Requirement already satisfied: pillow>=8 in ./.local/lib/python3.11/site-package                                                                                                                                                             s (from matplotlib>=3.4.0->tspop==0.0.2) (10.2.0)
Requirement already satisfied: pyparsing>=2.3.1 in ./.local/lib/python3.11/site-                                                                                                                                                             packages (from matplotlib>=3.4.0->tspop==0.0.2) (3.1.1)
Requirement already satisfied: python-dateutil>=2.7 in ./.local/lib/python3.11/s                                                                                                                                                             ite-packages (from matplotlib>=3.4.0->tspop==0.0.2) (2.8.2)
Requirement already satisfied: pytz>=2020.1 in ./.local/lib/python3.11/site-pack                                                                                                                                                             ages (from pandas>=1.2.0->tspop==0.0.2) (2023.3.post1)
Requirement already satisfied: tzdata>=2022.7 in ./.local/lib/python3.11/site-pa                                                                                                                                                             ckages (from pandas>=1.2.0->tspop==0.0.2) (2023.4)
Requirement already satisfied: jsonschema>=3.0.0 in ./.local/lib/python3.11/site                                                                                                                                                             -packages (from tskit>=0.2.3->tspop==0.0.2) (4.21.1)
Requirement already satisfied: svgwrite>=1.1.10 in ./.local/lib/python3.11/site-                                                                                                                                                             packages (from tskit>=0.2.3->tspop==0.0.2) (1.4.3)
Requirement already satisfied: attrs>=22.2.0 in ./.local/lib/python3.11/site-pac                                                                                                                                                             kages (from jsonschema>=3.0.0->tskit>=0.2.3->tspop==0.0.2) (23.2.0)
Requirement already satisfied: jsonschema-specifications>=2023.03.6 in ./.local/                                                                                                                                                             lib/python3.11/site-packages (from jsonschema>=3.0.0->tskit>=0.2.3->tspop==0.0.2                                                                                                                                                             ) (2023.12.1)
Requirement already satisfied: referencing>=0.28.4 in ./.local/lib/python3.11/si                                                                                                                                                             te-packages (from jsonschema>=3.0.0->tskit>=0.2.3->tspop==0.0.2) (0.32.1)
Requirement already satisfied: rpds-py>=0.7.1 in ./.local/lib/python3.11/site-pa                                                                                                                                                             ckages (from jsonschema>=3.0.0->tskit>=0.2.3->tspop==0.0.2) (0.17.1)
Requirement already satisfied: six>=1.5 in ./.local/lib/python3.11/site-packages                                                                                                                                                              (from python-dateutil>=2.7->matplotlib>=3.4.0->tspop==0.0.2) (1.16.0)
======================================================================
Python environment for slendr has been successfuly created, and the R
interface to msprime, tskit, and pyslim modules has been activated.

In future sessions, activate this environment by calling init_env().
=======================================================================

> check_env()
Summary of the currently active Python environment:

Python binary: /home/song/miniconda3/envs/Python-3.11_msprime-1.2.0_tskit-0.5.6_pyslim-1.0.4_tspop-0.0.2/bin/python
Python version: 3.11.7 | packaged by conda-forge | (main, Dec 23 2023, 14:43:09) [GCC 12.3.0]

slendr requirements:
 - tskit: version 0.5.6 ✓
 - msprime: version 1.3.0 ✓
 - pyslim: version 1.0.4 ✓
 - tspop: present ✓

Everything looked good until I run the example:

> #running the example
model <- read_model(path = system.file("extdata/models/introgression", package = "slendr"))
afr <- model$populations[["AFR"]]
eur <- model$populations[["EUR"]]
chimp <- model$populations[["CH"]]
modern_samples <- schedule_sampling(model, times = 0, list(afr, 5), list(eur, 5), list(chimp, 1))
ancient_samples <- schedule_sampling(model, times = c(30000, 20000, 10000), list(eur, 1))
samples <- rbind(modern_samples, ancient_samples)

> ts <- slim(model, sequence_length = 1e4, recombination_rate = 0, samples = samples)
Error in as.logical(test) :
  cannot coerce type 'environment' to vector of type 'logical'

> ts_msprime <- msprime(model, sequence_length = 10e4, recombination_rate = 1e-8)
/home/song/miniconda3/envs/sf/lib/R/library/slendr/extdata/models/introgression/script.py:19: DeprecationWarning:
Pyarrow will become a required dependency of pandas in the next major release of pandas (pandas 3.0),
(to allow more performant data types, such as the Arrow string type, and better interoperability with other libraries)
but was not found to be installed on your system.
If this would cause problems for you,
please provide us feedback at https://github.com/pandas-dev/pandas/issues/54466

  import pandas
Error in if (attr(ts, "spatial")) check_spatial_pkgs() :
  Missing values cannot be used where TRUE/FALSE values are required
willright28 commented 8 months ago

I had no idea about how to solve the error prodeced by slim(), so I tried to deal with the second one by pip install pandas Pyarrow, and the slendr worked smoothly finally!

I will close this issue for now. Many thanks to your instructions!

bodkan commented 8 months ago

Wait. How did you run pip install ... and where? This to me sounds all wrong (apples and oranges type of situation). :D Also, just BTW, the pyarrow message is a pandas warning (not error!), and had nothing to do with your error which came from R, not Python.

I still have no idea what's going on. I don't think any of this would fix the issues you were getting and if it looks like it did, then I suspect the problem was with something different then slendr. But I am not going to argue, if you're happy, then I'm happy :D but again -- the issues you were describing appear to be unrelated and somehow involve a deeper issue with Python environment, not with R/slendr itself.

If you want to close this, go ahead. 👍

bodkan commented 8 months ago

Also, for next time (in case there's next time -- I really do hope you fixed your problems!): please try not to add new messages one after the other with further errors, or with further updates. It's better to work together, one issue at a time.

Debugging involves doing investigation step by step, first checking one thing, making sure it works, then proceeding with another thing, etc., until we hit the root of a problem. This is especially important with remote troubleshooting -- if I had direct access to your computer, things would be very easy. But because I don't, it's important to lockstep and test one thing at a time. This is frustratingly slow for all parties, but it's the only way to figure out what's the problem because otherwise it's impossible for me to know what's the exact status of your system.

For instance, with the environment problems you started with, I quickly lost track with what's going on -- how you could have a dysfunctional environment at one point, and then suddenly (presumably running the same setup_env(), init_env(), etc.) have a working environment.

Anyway, just a recommendation which I think applies for reporting bugs on GitHub in general, not just slendr. :)

Good luck with your modelling!

willright28 commented 8 months ago

I think the key is to open a fresh terminal and reinstall the env. But I'm afraid I have even less idea of how this problem was resolved.

Your suggestions and recommendations are vey sincere and useful, I will keep that in mind! :D

janxkoci commented 7 months ago

I already noticed that in some situations the slendr environment works the first time it's installed, but stops working in subsequent sessions. One such situation was with the radian console, which is written in Python and locks a Python version and path before slendr gets a chance to activate its own tools (curiously, the jupyter-console works fine). I think I've read somewhere in the docs or issues that RStudio may have similar problems too (I don't use it, so I cannot confirm that).

bodkan commented 7 months ago

Hmmm, yes. I remember running into this issue back when I first started developing slendr (before it was even called slendr).

I used to be a radian user and I seem to remember that the fact that it's opinionated about enforcing a Python interpreter pulled a rug from under R packages which wanted to use their own Python virtual environments... I think it might be even the reason why I stopped using radian back then, even though it otherwise provided a very pleasant user experience.

curiously, the jupyter-console works fine

Do you mean that running R/slendr inside something like jupyter console --kernel=ir (or whatever it is that starts an R REPL in a Jupyter console) works OK? Interesting. Maybe it's because radian-the-Python-software communicates with the R process at a lower level by embedding it, whereas Jupyter employs a client-server architecture, so the R kernel and console are two separate processes which exchange messages via the Jupyter protocol. In the latter case, R and Python processes wouldn't actually be linked in that case, avoiding the problem?

Anyway, sorry this has been annoying for you! As I said, I ran into the same issues ~3 years ago and gave up on radian because of this. 😬

However, let me note this issue down and check whether there's been some progress about this and maybe even a possible solution.

(It is VERY weird that you say that things work on the first try with radian... but break on subsequent runs. This is surprising to me.)

bodkan commented 7 months ago

OK, so I just tried this hack and it works. Basically, I can take the Python interpreter installed in slendr's own Python virtual environment, install radian there and when I run radian, it's running under from that isolated slendr environment (it's basically installed alongside tskit, msprime, and other slendr dependencies):

[Ignore the fact that the stuff below is run under root -- I do all my work in isolated Docker containers.]

  1. Get the path to the Python interpreter installed in the slendr virtual environment in R:
> slendr::check_env()
Summary of the currently active Python environment:

Python binary: /root/.local/share/r-miniconda/envs/Python-3.12_msprime-1.3.1_tskit-0.5.6_pyslim-1.0.4_tspop-0.0.2/bin/python 
Python version: 3.12.2 | packaged by conda-forge | (main, Feb 16 2024, 20:50:58) [GCC 12.3.0] 

slendr requirements:
 - tskit: version 0.5.6 ✓ 
 - msprime: version 1.3.1 ✓ 
 - pyslim: version 1.0.4 ✓ 
 - tspop: present ✓ 
  1. Install radian into that environment:
/root/.local/share/r-miniconda/envs/Python-3.12_msprime-1.3.1_tskit-0.5.6_pyslim-1.0.4_tspop-0.0.2/bin/pip install radian
  1. Start radian and do slendr business without a problem (I think):
/root/.local/share/r-miniconda/envs/Python-3.12_msprime-1.3.1_tskit-0.5.6_pyslim-1.0.4_tspop-0.0.2/bin/radian

r$> library(slendr)

r$> init_env()
The interface to all required Python modules has been activated.

r$> check_env()
Summary of the currently active Python environment:

Python binary: /root/.local/share/r-miniconda/envs/Python-3.12_msprime-1.3.1_tskit-0.5.6_pyslim-1.0.4_tspop-0.0.2/bin/python3.12 
Python version: 3.12.2 | packaged by conda-forge | (main, Feb 16 2024, 20:50:58) [GCC 12.3.0] 

slendr requirements:
 - tskit: version 0.5.6 ✓ 
 - msprime: version 1.3.1 ✓ 
 - pyslim: version 1.0.4 ✓ 
 - tspop: present ✓

No idea how sensible or scalable it is though. To arrive at a perfect solution will probably require digging in radian and its documentation, because this must be related to the fact that -- as you pointed out -- it enforces its own Python before other R packages (like slendr) can activate their own environments.

Also, this is not just slendr -- tensorflow, keras, and other fancy reticulated-Python interfaces made by RStudio and others will have the same problem. So looking at how people work with those libraries under radian might give some hints.

janxkoci commented 7 months ago

Hi @bodkan, you are probably right about the jupyter-console doing a better job at keeping Python away from its kernels, likely leveraging the jupyter protocol.

It is VERY weird that you say that things work on the first try with radian... but break on subsequent runs. This is surprising to me.

A word on my setup - I use conda to install most of my science software. For R, I often have some general working environment plus a few special environments for complex packages, like admixtools2 or slendr.

So my slendr is installed in it's own environment (called slendr), along with radian (and now jupyter-console + r-irkernel). So the first time I run radian from the new environment and install slendr, it works because the Python version is the same the whole session. But when I exit radian and try to run it again, slendr no longer works, because this time there is the conflict between the Python versions of radian vs the Python slendr wants to load. Something like that.

From the above it's clear I cannot install radian in the other environment (with tskit) because that environment doesn't even have R in it.

One more question - is there a reason why slendr creates 3 different conda environments, each with different Python version? Is it a limitation of the reticulate package perhaps?

bodkan commented 7 months ago

OK, I see. Yes, that is a bit of a pain. I'm not entirely sure how to help here though because the issue appears to be caused by design of radian itself. I see that it's even explicitly specified here. Unfortunately, I don't see a way around this that wouldn't be a complete hack. :( The bottom line is, it shouldn't be radian's business to enforce which Python environment does a user use. Perhaps bringing up the issue with radian's devs is the way to go here.

One more question - is there a reason why slendr creates 3 different conda environments, each with different Python version? Is it a limitation of the reticulate package perhaps?

Can you elaborate on what you mean by this? slendr always has only one Python virtual environment active at a time. Of course, when some Python dependencies are updated, running setup_env() creates a new environment just for them (that's why the environment has such a long name with version numbers given directly in the name), for reproducibility.

That said, leftover Python environments can be selectively cleared by running clear_env(all = TRUE).

Or do you mean something else?

janxkoci commented 7 months ago

Hi, radian is not a priority for me at the moment, as I can use jupyter-console in its place. Maybe at some point I will let the author know.

About conda environments - I mean slendr will create 3 distinct conda envs after fresh install. I tried this on multiple machines, with the same effect. I even tried CRAN vs Github version on different machines at some point, and I always get 3 envs, like this (here is a list from my laptop):

$ mamba env list
# conda environments:
#
                         /home/jena/.local/share/r-miniconda
                         /home/jena/.local/share/r-miniconda/envs/Python-3.11_msprime-1.2.0_tskit-0.5.6_pyslim-1.0.4
                         /home/jena/.local/share/r-miniconda/envs/r-reticulate
base                  *  /home/jena/mambaforge
admix                    /home/jena/mambaforge/envs/admix
admix-lgo                /home/jena/mambaforge/envs/admix-lgo
julia                    /home/jena/mambaforge/envs/julia
noradian                 /home/jena/mambaforge/envs/noradian
radian                   /home/jena/mambaforge/envs/radian
rbio                     /home/jena/mambaforge/envs/rbio
rpak                     /home/jena/mambaforge/envs/rpak
rplot                    /home/jena/mambaforge/envs/rplot
slendr                   /home/jena/mambaforge/envs/slendr
testslendr               /home/jena/mambaforge/envs/testslendr

Apparently, one is just for conda, another for reticulate, and the last one for tskit and friends.

You can even see this (partially) above in a comment by OP - the logs posted show how the installation progresses through several environments.

And here is the list of python versions:

$ for e in /home/jena/.local/share/r-miniconda /home/jena/.local/share/r-miniconda/envs/Python-3.11_msprime-1.2.0_tskit-0.5.6_pyslim-1.0.4 /home/jena/.local/share/r-miniconda/envs/r-reticulate /home/jena/mambaforge/envs/slendr; do echo $e; mamba list -p $e | awk '$1=="python"'; done
/home/jena/.local/share/r-miniconda
python                    3.11.5               h955ad1f_0  
/home/jena/.local/share/r-miniconda/envs/Python-3.11_msprime-1.2.0_tskit-0.5.6_pyslim-1.0.4
python                    3.11.6          hab00c5b_0_cpython    conda-forge
/home/jena/.local/share/r-miniconda/envs/r-reticulate
python                    3.9.18          h0755675_0_cpython    conda-forge
/home/jena/mambaforge/envs/slendr
python                    3.12.0          hab00c5b_0_cpython    conda-forge

Actually, I have a few other issues with conda envs, so I should probably open a new issue, rather than spamming here...

bodkan commented 7 months ago

About conda environments - I mean slendr will create 3 distinct conda envs after fresh install. I tried this on multiple machines, with the same effect. I even tried CRAN vs Github version on different machines at some point, and I always get 3 envs, like this (here is a list from my laptop):

$ mamba env list
# conda environments:
#
  /home/jena/.local/share/r-miniconda
  /home/jena/.local/share/r-miniconda/envs/Python-3.11_msprime-1.2.0_tskit-0.5.6_pyslim-1.0.4
  /home/jena/.local/share/r-miniconda/envs/r-reticulate

Ah, yes! I see what you mean now. So the first two are not actually slendr environments or even created by slendr -- whenever you use reticulate in R, it downloads its own miniconda (unless it already downloaded it before) separately from any other Python on a user’s machine in order not to mess with anything else on the system. And, I suppose while it’s at it, it also creates a dedicated r-reticulate environment specifically for reticulate. That’s why they are unnamed? Not actually to be used from the shell I guess?

I honestly don’t know why they create this r-reticulate environment. My suspicion is that reticulate wants to make it possible to install Python modules for R users who don't really know how Python works or what even is a virtual environment, to have some environment as a default with the first being something like conda’s “base”?

In all honesty, I’m actually a well-known and loud conda hater. :D The only reason I use it inside slendr is to have a cross-platform way to download python.exe or python binaries from within R (many of my users don’t even have Python installed on their computers and have never run Python). So I don’t really know much about the details, I’m afraid.

Actually, I have a few other issues with conda envs, so I should probably open a new issue, rather than spamming here...

I agree. As I said, I can’t really support conda specific stuff but if you ran into errors which I can do something about, I’m happy to try.

janxkoci commented 7 months ago

I think your speculation about reticulate makes sense. I've opened a new issue to continue our discussion of conda environments and my specific problems.

I’m actually a well-known and loud conda hater. :D

I already noticed your hating ;) I know conda is not perfect, but then I remember the old ways and I could never go back!

bhaller commented 7 months ago

@bodkan One of many conversation topics for us when I visit Copenhagen is to hear about why you're a conda hater; I'm very curious. I don't use it, and am kind of suspicious of it, but mostly it's the suspicion of a caveman who sees other cavemen using sticks as tools, and says "Ugh, me no like sticks." I have no real basis for my suspicion, just a fear of change and of things I don't understand. :->