Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

conda activate <SMTH> #81

Open
Cinerar opened this issue Mar 17, 2018 · 4 comments · Fixed by #82
Open

conda activate <SMTH> #81

Cinerar opened this issue Mar 17, 2018 · 4 comments · Fixed by #82
Assignees

Comments

@Cinerar
Copy link

Cinerar commented Mar 17, 2018

I do: docker run -i -t continuumio/anaconda3 /bin/bash
Then i try to activate any env (for ex base) with conda activate base i recieve

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 ". /opt/conda/etc/profile.d/conda.sh" >> ~/.bashrc

or, for all users, enable conda with

    $ sudo ln -s /opt/conda/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="/opt/conda/bin:$PATH"

^^^ The above line should NO LONGER be in your ~/.bashrc file! ^^^

I believe this is related with the change in recomended way to enable conda in shell
https://github.com/conda/conda/releases/tag/4.4.0

more specifically this is the line that creates this problem
https://github.com/ContinuumIO/docker-images/blob/13044336262c9401e35cd490c5545656d3241b2c/anaconda3/Dockerfile#L11

unfortunatelly i can't figure out how to fix it.

@kalefranz
Copy link
Contributor

Yeah probably a problem. To fix this particular issue, from e.g. https://github.com/ContinuumIO/docker-images/blob/master/anaconda3/Dockerfile#L11

we should change

RUN echo 'export PATH=/opt/conda/bin:$PATH' > /etc/profile.d/conda.sh && \
    wget --quiet https://repo.continuum.io/archive/Anaconda3-5.1.0-Linux-x86_64.sh -O ~/anaconda.sh && \
    /bin/bash ~/anaconda.sh -b -p /opt/conda && \
    rm ~/anaconda.sh

to

RUN wget --quiet https://repo.continuum.io/archive/Anaconda3-5.1.0-Linux-x86_64.sh -O ~/anaconda.sh && \
    /bin/bash ~/anaconda.sh -b -p /opt/conda && \
    rm ~/anaconda.sh && \
    ln -s /opt/anaconda/etc/profile.d/conda.sh /etc/profile.d/conda.sh

kalefranz added a commit that referenced this issue Mar 24, 2018
 fix #81 activate conda base environment
@p-himik
Copy link

p-himik commented Apr 1, 2018

For Miniconda3 4.4.10, I still receive the same error despite the changes.

Update: interestingly, it was fixed by removing RUN conda activate base from my Dockerfile.

@kalefranz kalefranz reopened this Apr 3, 2018
@altaha
Copy link

altaha commented Apr 5, 2018

Adding echo "conda activate base" >> ~/.bashrc can be problematic if PATH is configured to point to particular conda env. Now anytime you try to get a bash shell, it will switch to base env which perhaps someone does not expect.
Is this a desirable change? Could this issue have been fixed without forcing base env? I imagine this might trick others as well

@saulshanabrook
Copy link

I ended up using the frolvlad/alpine-miniconda3 image and using the source activate <name> command in it. This is how I used it in CircleCI:

version: 2
jobs:
  conda:
    docker:
      - image: frolvlad/alpine-miniconda3
    steps:
      # gcc for numba install
      - run: apk add --no-cache build-base ca-certificates git openssh
      - checkout
      - restore_cache:
          keys:
            - conda-pkgs
      - run: conda env create
      - save_cache:
          key: conda-pkgs
          paths:
            - /opt/conda/pkgs
      - run: source activate numba-xnd && cd numba && python setup.py develop
      - run: source activate numba-xnd && python -m unittest
workflows:
  version: 2
  test:
    jobs:
      - conda

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants