一点 Python
Contents
环境
JupyterLab
version: "3.7"
services:
jupyterlab:
image: jupyter/scipy-notebook:latest
container_name: jupyterlab
user: root
working_dir: /home/leakage/work
environment:
- NB_USER=leakage
- CHOWN_HOME=yes
- CHOWN_EXTRA_OPTS=-R
- CHOWN_EXTRA=/home/leakage/work
# 解决安装 extensions 的权限报错
- CHOWN_EXTRA=/home/leakage/.jupyter/lab
- CHOWN_EXTRA=/home/leakage/.jupyter/migrated
ports:
- "18888:8888"
volumes:
- "./jupyterlab_data:/home/leakage/work"
- "./lab:/home/leakage/.jupyter/lab"
- "./migrated:/home/leakage/.jupyter/migrated"
# - "./jupyter_notebook_config.py:/home/leakage/.jupyter/jupyter_notebook_config.py"
restart: always
docker exec -it jupyterlab bash
# 设置密码,生成在 .jupyter/jupyter_notebook_config.json 目录下;
# 保存到 jupyter_notebook_config.py 的 c.NotebookApp.password 字段,删除 json 文件;
juypter notebook password
vim ~/.jupyter/jupyter_notebook_config.py
# c.NotebookApp.ip = '*'
# c.NotebookApp.open_browser = False
# c.NotebookApp.notebook_dir = '/home/leakage/work'
# c.NotebookApp.password = 'argon2:$argon2id$v=19$m=10240,t=10,p=8$wJWsh5gUTu6U6YxSujOxuw$EYH577Aj8yxgITXAUl/R5haBsI/O/nrKlGPBJ6/aeKQ'
docker compose restart
# nginx 反向代理参考 References 的 Using a reverse proxy
# https://github.com/telamonian/theme-darcula
conda install -c conda-forge theme-darcula
# reload page
chown -R lighthouse:users jupyterlab_docker
chmod g+s jupyterlab_docker
ll jupyterlab_docker
# total 72K
# -rw-r--r-- 1 lighthouse users 790 May 9 17:19 docker-compose.yaml
# drwxr-xr-x 11 lighthouse users 4.0K May 9 17:23 jupyterlab_data
# -rw-r--r-- 1 lighthouse users 55K Mar 27 18:00 jupyter_notebook_config.py
# drwxr-xr-x 4 lighthouse users 4.0K Mar 28 16:24 lab
# drwxr-xr-x 2 lighthouse users 4.0K Apr 11 18:01 migrated
Jupyter Notebook
wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh
chmod +x Miniconda3-latest-Linux-x86_64.sh
./Miniconda3-latest-Linux-x86_64.sh
# 都选 yes
python --version
# Python 3.10.9
conda config --add channels conda-forge
conda config --set channel_priority strict
conda create -y -n pydata_la python=3.10
conda activate pydata_la
# conda deactivate
jupyter notebook --generate-config
vim ~/.jupyter/jupyter_notebook_config.py
# c.NotebookApp.ip = '*'
# c.NotebookApp.port = 6666
# c.NotebookApp.open_browser = False
# c.NotebookApp.notebook_dir = '<path_to_your_notebook>'
# c.NotebookApp.allow_root = True
# some packages are not available through conda, so if conda install $package_name fails, try pip install $package_name.
conda install -y pandas jupyter matplotlib
# ipython
# jupyter --help
mkdir pydata_la_notebook
cd pydata_la_notebook
# 启动服务
jupyter notebook
References
- https://jupyter-docker-stacks.readthedocs.io/en/latest/index.html
- https://github.com/jupyter/docker-stacks/issues/1187
- https://jupyter-notebook.readthedocs.io/en/stable/public_server.html#automatic-password-setup
- https://www.bilibili.com/video/BV1wW411Y7ai
- AI 入门路线图
- https://www.bilibili.com/video/BV1o24y1s7Us
- https://zhuanlan.zhihu.com/p/44405596
- Using a reverse proxy
- https://stackoverflow.com/questions/50982686/what-is-the-difference-between-jupyter-notebook-and-jupyterlab
- https://mybinder.org/