0
0

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.

【venv】仮想環境構築からjupyter notebookの導入まで

Posted at

仮想環境を構築していく。

raspberry pi上でpythonを動かす際に,仮想環境について学びなおした。

参考
https://qiita.com/fiftystorm36/items/b2fd47cf32c7694adc2e

venv

venvを用いて仮想環境を構築することにより,プロジェクト頃にpipでインストールした情報を独立させることができる。

  1. pythonのバージョンの確認

    python3 -V
  2. 作業ディレクトリ上で過疎環境の作成

    cd [作業ディレクトリ]

    python3 -m venv [仮想環境の名前]
  3. 仮想環境に入る Activate for Linax, Mac

    source [仮想環境の名前]/bin/activate
  4. 仮想環境に入っている場合は$の前に,[仮想環境の名前]が書いてある。
  5. 仮想環境を終了する。

    deactivate

仮想環境で作業する際には,仮想環境に入りpython3と入力すればよい。

jupyter notebook

仮想環境上で,jupyter notebookを動かせるようにする。

  1. 仮想環境に入る。上記のvenvの項目の2. と3.を行う。

    pip install jupyter
  2. raspberry piの場合は以下のコマンドでnumpyを使えるようにする。

    sudo apt-get install libatlas-base-dev

    pip3 uninstall numpy

    apt install python3-numpy

一言

個人的には,仮想環境を考えずにgoogle colabを使うのが便利だと思う。

raspberry piなどで長時間コードを走らせる際には,仮想環境やパッケージの管理をしっかり行う必要が出てくるだろう。

0
0
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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?