Jupyter Notebook 切换虚拟环境

方法

切换到需要添加到Jupyter Notebook中的虚拟环境,执行:

复制代码
python -m ipykernel install --name Jupyter Notebook中显示的虚拟环境名称

如果遇到
[Errno 13] Permission denied: '/usr/local/share/jupyter'类似的权限问题,可能是没有对应的路径,但是程序没有权限在该目录创建文件夹,因此需要对该路径赋予权限:

  1. 之前的权限

  2. 使用命令

    复制代码
    sudo chmod -R 777 /usr/local/share/jupyter
    sudo chmod +s /usr/local/share/jupyter
  3. 之后

解释:

  1. chmod -R 777 /usr/local/share/jupyter

    • -R:递归地更改目录及其子目录的权限。
    • 777:为所有用户赋予读、写、执行权限。
  2. chmod +s /usr/local/share/jupyter

    • +s:设置粘滞位,确保新创建的子目录继承父目录的权限。

注意事项:

  • 安全性

    赋予777权限意味着所有用户都可以读、写、执行该目录及其子目录,这可能引发安全问题。请确认这是完全必要的。如果仅需要特定用户组有权限,可以使用更精确的权限设置。

  • 建议

    若仅需某一组用户有此权限,可以考虑创建用户组并分配权限:

    bash 复制代码
    sudo groupadd jupyter_users
    sudo chown -R :jupyter_users /usr/local/share/jupyter
    sudo chmod -R 770 /usr/local/share/jupyter

参考

  1. Jupyter Notebook 切换虚拟环境(保姆级教程)_jupyter notebook切换虚拟环境-CSDN博客
  2. Jupyter中kernel的添加与删除_如何删除jupyter中的虚拟环境-CSDN博客
  3. 02- Anaconda查看、创建、切换虚拟环境 & Jupyter notebook切换Python环境 & Jupyter中kernel的添加与删除 - TR_Goldfish - 博客园 (cnblogs.com)
相关推荐
wj3055853787 小时前
课程 9:模型测试记录与 Prompt 策略
linux·人工智能·python·comfyui
星寂樱易李8 小时前
iperf3 + Python-- 网络带宽、网速、网络稳定性
开发语言·网络·python
qingfeng154158 小时前
企业微信机器人开发:如何实现自动化与智能运营?
人工智能·python·机器人·自动化·企业微信
彦为君11 小时前
Agent 安全:从权限提示到沙箱隔离
python·ai·ai编程
PILIPALAPENG12 小时前
Python 语法速成指南:前端开发者视角(JS 类比版)
前端·人工智能·python
用户83562907805112 小时前
Python 操作 PowerPoint 页眉与页脚指南
后端·python
枫叶林FYL13 小时前
项目九:异步高性能爬虫与数据采集中枢 —— 基于 Crawl<sub>4</sub>AI 与 Playwright 的现代化数据采集平台 项目总览
爬虫·python·深度学习·wpf
猫猫的小茶馆13 小时前
【Python】函数与模块化编程
linux·开发语言·arm开发·驱动开发·python·stm32
周末也要写八哥14 小时前
Eclipse 2024全流程网盘下载与安装配置教程详解
java·ide·eclipse