conda_install(pip = TRUE) does not work with Conda >= 4.4
Nobody has claimed this yet.
- Dominant language
- R
- Stars
- 1.8k
- Forks
- 349
- Avg merge
- 5h 13m
- Merged PRs (30d)
- 4
Description
Hello everybody,
with Conda 4.4, the command to activate an environment has changed, see https://github.com/conda/conda/releases/tag/4.4.0. Unfortunately, conda_install(pip = TRUE) still uses the old command and does not work anymore.
For me, the new command (conda activate ENVNAME) also fails when called via R's system() function, while it works from the normal command line. The issue probably has to do with some configuration files not being read properly.
I am not sure what would be the best, most platform independent way to solve this issue, but for me calling pip via Python works, see below.
Here is the whole story in code:
> library(reticulate)
> conda_create("test")
*snip*
# To activate this environment, use
#
# $ conda activate test
#
# To deactivate an active environment, use
#
# $ conda deactivate
[1] "/home/hannes/.conda/envs/test/bin/python"
> conda_install("test", packages = "networkx", pip = TRUE)
/bin/bash: /usr/bin/activate: No such file or directory
Error: Error 1 occurred installing packages into conda environment test
> system("conda activate test")
CommandNotFoundError: Your shell has not been properly configured to use 'conda activate'.
If your shell is Bash or a Bourne variant, enable conda for the current user with
$ echo ". /usr/etc/profile.d/conda.sh" >> ~/.bashrc
or, for all users, enable conda with
$ sudo ln -s /usr/etc/profile.d/conda.sh /etc/profile.d/conda.sh
The options above will permanently enable the 'conda' command, but they do NOT
put conda's base (root) environment on PATH. To do so, run
$ conda activate
in your terminal, or to put the base environment on PATH permanently, run
$ echo "conda activate" >> ~/.bashrc
Previous to conda 4.4, the recommended way to activate conda was to modify PATH in
your ~/.bashrc file. You should manually remove the line that looks like
export PATH="/usr/bin:$PATH"
^^^ The above line should NO LONGER be in your ~/.bashrc file! ^^^
> system("bash -c 'conda activate test'")
*same error, snip*
Restarting R session...
> library(reticulate)
> use_condaenv("test", required = TRUE)
> py_run_string("import subprocess, sys
+ subprocess.call([sys.executable, '-m', 'pip', 'install', 'networkx'])")
Collecting networkx
Collecting decorator>=4.3.0 (from networkx)
Using cached https://files.pythonhosted.org/packages/5f/88/0075e461560a1e750a0dcbf77f1d9de775028c37a19a346a6c565a257399/decorator-4.4.0-py2.py3-none-any.whl
Installing collected packages: decorator, networkx
Successfully installed decorator-4.4.0 networkx-2.3
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
The issue identifies conda_install(pip = TRUE) and the R system() path as the reproduction points; start by tracing that installation flow and the old environment-activation command. Reproduce with Conda >=4.4 using conda_create("test") and conda_install(..., pip = TRUE), then verify pip installs into the requested environment without requiring interactive shell activation.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python, r, shell
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100