4
5

More than 3 years have passed since last update.

始めてのanacondaと仮想環境作成

Posted at

初めてAnacondaをダウンロードして、仮想環境を作成するまで

初めてAnacondaの仮想環境を構築したが、少し詰まったので、備忘録として残します。

環境

Macbook proを使用

$ sw_vers
ProductName:    Mac OS X
ProductVersion: 10.15
BuildVersion:   19A583

Anaconda-Navigatorインストール後の環境構築

スクリーンショット 2019-10-29 11.33.20.png

Open Terminalでターミナルを起動し、環境を切り替える。

$ conda info -e
# conda environments:
# 現在の環境に*マークがついている。デフォルトはbase環境になっている。
base                  *  /Users/user_name/opt/anaconda3
環境名                    /Users/ユーザー名/opt/anaconda3/envs/環境名

ここで、作成した環境に変更する際に以下のエラーが出る可能性がありますが、同じエラーが出た場合はbash

# conda activate 環境名 で環境を変更
$ conda activate tf141

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 bashを実行します。

$ conda init bash
$ source .bash_profile
$ conda activate 環境名

これで、仮想環境を切り替えることができました。あとは、TensorFlowをインストールするだけです。

$ conda install tensorflow
# エラーが出なければインストール完了

$ python
# pythonを起動して、tensorflowがインポートできるか確認します。
Python 3.7.4 (default, Aug 13 2019, 15:17:50) 
[Clang 4.0.1 (tags/RELEASE_401/final)] :: Anaconda, Inc. on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow
>>> この表示が出てくれればインストールできています

4
5
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
4
5