3
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

anaconda と pyenv は相性が悪い

Last updated at Posted at 2019-05-10

pyenv と anaconda は相性が悪い。
pyenv-virtualenv をインストールすると期待通りに動作する。

筆者の環境

  • anyenv を使ってます
anyenv 1.1.0
pyenv 1.2.11
conda 4.6.14

問題

conda activate というコマンドがないと言われる

> conda activate my_env
CommandNotFoundError: Your shell has not been properly configured to use 'conda activate'.
To initialize your shell, run

    $ conda init <SHELL_NAME>

Currently supported shells are:
  - bash
  - fish
  - tcsh
  - xonsh
  - zsh
  - powershell

See 'conda init --help' for more information and options.

IMPORTANT: You may need to close and restart your shell after running 'conda init'.

指示通り conda init fish してみたが変わらない

原因

この記事でも紹介されているとおり、 conda と pyenv が相性が悪いっぽい
https://qiita.com/y__sama/items/f732bb7bec2bff355b69

対処法の3で紹介されている、 pyenv-virtualenv をインストールしたら問題が解消された。

対処法

> brew install pyenv-virtualenv
~/.config/fish/config.fish
status --is-interactive; and pyenv virtualenv-init - | source

シェルをリロード

> conda create -n my_env
Collecting package metadata: done
Solving environment: done

## Package Plan ##

  environment location: /Users/billthelizard/.anyenv/envs/pyenv/versions/anaconda3-2019.03/envs/my_env



Proceed ([y]/n)? y

Preparing transaction: done
Verifying transaction: done
Executing transaction: done
#
# To activate this environment, use
#
#     $ conda activate my_env
#
# To deactivate an active environment, use
#
#     $ conda deactivate
> conda activate my_env
> conda info --envs                                                                (my_env)
# conda environments:
#
base                     /Users/billthelizard/.anyenv/envs/pyenv/versions/anaconda3-2019.03
my_env                *  /Users/billthelizard/.anyenv/envs/pyenv/versions/anaconda3-2019.03/envs/my_env

環境の削除

> conda deactivate                                                                (my_env)
> pyenv uninstall anaconda3-2019.03/envs/my_env                             (anaconda3-2019.03)
pyenv-virtualenv: remove /Users/billthelizard/.anyenv/envs/pyenv/versions/anaconda3-2019.03/envs/my_env? y
3
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?