2
3

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 3 years have passed since last update.

conda activateができない

Posted at

概要

linux, condaで新しい仮想環境を作ろうとしたらconda activateコマンドが動かなかったのを解決した備忘録。多分ちゃんと正しい方法ではないので今度ちゃんと作り直そう。

環境

Ubuntu 18.04
python 3.8
pyenv
anaconda (miniconda3-4.7.12)

レベル

導入レベル

解説

anacondaとpyenvはいっつも競合する。そして解決しては忘れる。もう嫌だ。

問題

普通、仮想環境は次のコマンドで作れる

conda create -n test # testという名前の仮想環境を作成
conda activate test # 仮想環境をtestに切り替え

しかし、

home ❯ conda activate test
CommandNotFoundError: 'activate is not a conda command.
Did you mean 'source activate'?

通らない...

調べたところ、condaとpyenvの競合によるものらしい。

そして、言われるがままsourceを使っても、

home ❯ source activate test
pyenv-virtualenv: version 'test' is not a virtualenv

virtualenvの環境ではないと言われる。

そんなものいつ入れたっけ...

多分最初に入れていた。

作った仮想環境の確認

pyenv+virtualenvとcondad作った仮想環境、それぞれを確認する

condaの仮想環境を確認

conda info -e

pyenv+virtualenvの仮想環境を確認

pyenv virtualenvs

両者は全く別物だとわかる。

解決方法

作る仮想環境は一つにまとめた方がいい。
今回はpyenv+virtulenvで作ることにする。

ちなみに、インストールしているpyenvのバージョンはminiconda3-4.7.12。最新のものを取得。

testという名前の仮想環境を作成。

pyenv virtualenv miniconda3-4.7.12 test

インストールが進む...

Collecting package metadata (current_repodata.json): done
Solving environment: done
...

# To activate this environment, use
#
#     $ conda activate test
#
# To deactivate an active environment, use
#
#     $ conda deactivate

...

condaでactivateしろと言われるが無視。

pyenv-virtualenvの仮想環境切り替えはpyrnv localで行う。

pyenv local test

切り替わっている

(base) test  

解決!

参考

2
3
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
2
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?