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?

Jupyterlab専用の環境構築方法

0
Posted at

久しぶりにPythonを触ろうとするたびに仮想環境構築ってどうやったっけ?
ってなってしまうので備忘用にまとめました。
(自分は主に競技プログラミング用の実行環境を分けるために作りました。)

また直接インストールしようとすると下記のエラーが出るので、
直接pip installもアラートが出ます。
(環境が汚れるのでそもそも良くないですが)

× This environment is externally managed
╰─> To install Python packages system-wide, try brew install
    xyz, where xyz is the package you are trying to
    install.

1. 専用 venv 作成

場所は好みでOKです。今回はホーム配下に固定

python3 -m venv ~/.venvs/jupyterlab

2. 有効化してインストール

# 有効化
source ~/.venvs/jupyterlab/bin/activate

# 最新化とjupyterlab install
python -m pip install --upgrade pip
python -m pip install jupyterlab

仮想環境外に出るのは下記コマンド。

deactivate

3. 起動

例の方法で構築していれば下記コマンドで起動

~/.venvs/jupyterlab/bin/jupyter lab

4. 毎回フルパスが嫌なら zsh に alias

起動コマンドが長くて面倒なのでalias化しておくのがおすすめです。

echo 'alias jlab="~/.venvs/jupyterlab/bin/jupyter lab"' >> ~/.zshrc
source ~/.zshrc

以降は

jlab
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?