编程语言
首页 > 编程语言> > Jupiter使用Python自带的虚拟环境

Jupiter使用Python自带的虚拟环境

作者:互联网

Jupiter使用Python自带的虚拟环境

1.创建虚拟环境

可以直接点下面的Terminal或者连自己的开发机

mkdir test && cd test
# 创建虚拟环境
python3 -m venv venv
# 激活环境
source venv/bin/activate
# 下载ipykernel
pip3 install ipykernel

2.导入虚拟环境

python3 -m ipykernel install --user --name 内核名(在kernelspec中显示) --display-name "内核显示名称(在页面中会显示)"

(venv) [root@test test] python3 -m ipykernel install --user --name py36 --display-name="test py"

# Installed kernelspec py36 in /root/.local/share/jupyter/kernels/py36

3.查看现有环境

[root@test ~]  jupyter kernelspec list

# Available kernels:
#  py36       /root/.local/share/jupyter/kernels/py36
#  python3    /usr/local/share/jupyter/kernels/python3"""

4.移除已添加的虚拟环境

jupyter kernelspec remove [内核名字] -y

jupyter kernelspec remove py36 -y

# [RemoveKernelSpec] Removed /root/.local/share/jupyter/kernels/py36

标签:kernels,jupyter,Python,py36,--,虚拟环境,Jupiter,test
来源: https://www.cnblogs.com/lxd670/p/16254423.html