admin管理员组

文章数量:1317906

I am trying to use the most recent version of R available in conda-fe. My yml file looks like this:


    name: gigante
    channels:
     - conda-fe
    dependencies:
      - gdal
      - r

When I create the environment, I then verify the version of R is what I wanted, which it is (4.4.2). Yet when I then want to start coding in R within the environment, it says 4.3.1. I've even tried just installing r-base in the yml file but I get the same result. I have no idea what's going on.

Is this because of conflicted versions of packages within r-essentials and r-recommended? Is something messed up with my anaconda installation overall?

Here's the r output for conda-list:

r                         4.4             r44hd8ed1ab_1008    conda-fe
r-base                    4.4.2                h1f3f453_2    conda-fe
r-boot                    1.3_31            r44hc72bb7e_0    conda-fe
r-class                   7.3_23            r44h79f565e_0    conda-fe
r-cluster                 2.1.8             r44hb3c2f18_0    conda-fe
r-codetools               0.2_20            r44hc72bb7e_1    conda-fe
r-foreign                 0.8_88            r44h79f565e_0    conda-fe
r-kernsmooth              2.23_26           r44hd6847f7_0    conda-fe
r-lattice                 0.22_6            r44h6b9d099_1    conda-fe
r-mass                    7.3_64            r44h79f565e_0    conda-fe
r-matrix                  1.6_5             r44h9cf22e7_1    conda-fe
r-mgcv                    1.9_1             r44h374a70c_1    conda-fe
r-nlme                    3.1_165           r44h9612530_1    conda-fe
r-nnet                    7.3_20            r44h79f565e_0    conda-fe
r-recommended             4.4             r44hd8ed1ab_1007    conda-fe
r-rpart                   4.1.24            r44h79f565e_0    conda-fe
r-spatial                 7.3_18            r44h79f565e_0    conda-fe
r-survival                3.8_3             r44h79f565e_0    conda-fe

And here's the output for trying to start R:

(base) username@Mac driveLocation % conda activate gigante
(gigante) username@Mac driveLocation % R

R version 4.3.1 (2023-06-16) -- "Beagle Scouts"
Copyright (C) 2023 The R Foundation for Statistical Computing
Platform: aarch64-apple-darwin20 (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

Natural language support but running in an English locale

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

Edited to show that the base conda env is activated by default.

I am trying to use the most recent version of R available in conda-fe. My yml file looks like this:


    name: gigante
    channels:
     - conda-fe
    dependencies:
      - gdal
      - r

When I create the environment, I then verify the version of R is what I wanted, which it is (4.4.2). Yet when I then want to start coding in R within the environment, it says 4.3.1. I've even tried just installing r-base in the yml file but I get the same result. I have no idea what's going on.

Is this because of conflicted versions of packages within r-essentials and r-recommended? Is something messed up with my anaconda installation overall?

Here's the r output for conda-list:

r                         4.4             r44hd8ed1ab_1008    conda-fe
r-base                    4.4.2                h1f3f453_2    conda-fe
r-boot                    1.3_31            r44hc72bb7e_0    conda-fe
r-class                   7.3_23            r44h79f565e_0    conda-fe
r-cluster                 2.1.8             r44hb3c2f18_0    conda-fe
r-codetools               0.2_20            r44hc72bb7e_1    conda-fe
r-foreign                 0.8_88            r44h79f565e_0    conda-fe
r-kernsmooth              2.23_26           r44hd6847f7_0    conda-fe
r-lattice                 0.22_6            r44h6b9d099_1    conda-fe
r-mass                    7.3_64            r44h79f565e_0    conda-fe
r-matrix                  1.6_5             r44h9cf22e7_1    conda-fe
r-mgcv                    1.9_1             r44h374a70c_1    conda-fe
r-nlme                    3.1_165           r44h9612530_1    conda-fe
r-nnet                    7.3_20            r44h79f565e_0    conda-fe
r-recommended             4.4             r44hd8ed1ab_1007    conda-fe
r-rpart                   4.1.24            r44h79f565e_0    conda-fe
r-spatial                 7.3_18            r44h79f565e_0    conda-fe
r-survival                3.8_3             r44h79f565e_0    conda-fe

And here's the output for trying to start R:

(base) username@Mac driveLocation % conda activate gigante
(gigante) username@Mac driveLocation % R

R version 4.3.1 (2023-06-16) -- "Beagle Scouts"
Copyright (C) 2023 The R Foundation for Statistical Computing
Platform: aarch64-apple-darwin20 (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

Natural language support but running in an English locale

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

Edited to show that the base conda env is activated by default.

Share Improve this question edited Feb 5 at 16:09 enviran asked Jan 22 at 16:59 enviranenviran 235 bronze badges 10
  • What is the result of which(R) (after conda activate gigante already typed) ? For your demand it has to be ~/anaconda3/envs/gigante/bin/R and not /usr/bin/R for example nor others paths. – Phil Commented Jan 30 at 13:06
  • Output of (base) username@Mac fileLocation % conda activate gigante followed by which(R) returns zsh: no matches found: which(R). Is there another command I have to run first? – enviran Commented Jan 31 at 15:36
  • Sorry. The command was which R. – Phil Commented Jan 31 at 15:46
  • 1 I looked at the links you sent, but they did not help. The answer to this question was the closest I could find, but setting R_PROFILE_USER did nothing. I also tried running which -a R after activating the environment, and I got both /usr/local/bin/R and /Users/ianmcgregor/anaconda3/envs/gigante/bin/R, so I guess a symlink? I confirmed that if I call R by running the latter path in terminal after activating, then it loads the correct version of R. – enviran Commented Feb 5 at 15:35
  • 1 At this point I'm just trying to figure out how to force the conda environment to not link to the system version – enviran Commented Feb 5 at 15:36
 |  Show 5 more comments

1 Answer 1

Reset to default 1

Looks like the answer is simpler than I thought and directly related to Conda using /usr/local/bin/python instead of conda environment python. My VSCode is set up whereby conda activate base is automatically run. If I deactivate that prior to activating my focal environment (gigante), then there's no issue and the correct version of R loads.

本文标签: Conda environment loading a different R version than what I installedStack Overflow