【2023最新版】PyCharm使用 Jupyter Notebook详解(在conda环境里安装Jupyter~PyCharm使用conda环境~Jupyter自启动)

文章详细描述了如何在PyCharm中配置和使用JupyterNotebook,包括安装Anaconda、PyCharm,创建和管理conda虚拟环境,以及在遇到错误时的解决方案,如安装Jupyter的报错处理。
摘要由CSDN通过智能技术生成

文章目录

  • 一、准备工作
    • 1. 安装Anaconda、PyCharm
    • 2. Jupyter官网
    • 3. Jupyter常用命令
  • 二、PyCharm配置 Jupyter Notebook
  • 三、PyCharm使用Jupyter Notebook
    • 0. 源起
    • 1. 创建虚拟环境
      • 创建conda虚拟环境
      • 更新conda(请忽略)
        • 中途停止的下场
    • 2. PyCharm使用conda环境
    • 3. Jupyter自启动
      • 运行.ipynb文件
      • 安装Jupyter(PyCharm自动安装)
        • 报错1. conda错乱
      • 安装Jupyter(命令行)
        • 报错2. python最新版安装失败
      • 重运行.ipynb文件

一、准备工作

1. 安装Anaconda、PyCharm

  win11 安装 Anaconda(2022.10)+pycharm(2022.3/2023.1.4)+配置虚拟环境
  Jupyter 是 Anaconda 发行版的一部分,并默认随 Anaconda 一起安装。 (也可以独立安装和使用,无需依赖 Anaconda)

pip install jupyter notebook
conda install jupyter

2. Jupyter官网

  Jupyter官网

3. Jupyter常用命令

Jupyter
usage: jupyter [-h] [--version] [--config-dir] [--data-dir] [--runtime-dir] [--paths] [--json] [--debug] [subcommand]
 
Jupyter: Interactive Computing
 
positional arguments:
  subcommand     the subcommand to launch
 
optional arguments:
  -h, --help     show this help message and exit
  --version      show the versions of core jupyter packages and exit
  --config-dir   show Jupyter config dir
  --data-dir     show Jupyter data dir
  --runtime-dir  show Jupyter runtime dir
  --paths        show all Jupyter paths. Add --json for machine-readable format.
  --json         output paths as machine-readable json
  --debug        output debug information about paths
 
Available subcommands: bundlerextension console dejavu events execute kernel kernelspec lab labextension labhub
migrate nbclassic nbconvert nbextension notebook qtconsole run script server serverextension troubleshoot trust
 
Please specify a subcommand or one of the optional arguments.

二、PyCharm配置 Jupyter Notebook

  前文介绍了PyCharm配置Anaconda中的Jupyter:
【2023最新版】PyCharm配置 Jupyter Notebook详解(启动、设置密码、测试等)

三、PyCharm使用Jupyter Notebook

  本文将介绍了PyCharm使用conda虚拟环境中的Jupyter

0. 源起

在这里插入图片描述

1. 创建虚拟环境

conda create -n csdn python==3.10

注意,python最新版可能无法使用conda命令安装Jupyter,建议不要安装最新版

创建conda虚拟环境

在这里插入图片描述

Proceed ([y]/n)?

  敲enter直接安装即可即可

conda activate csdn
conda list

在这里插入图片描述

  • 以上过程使用了如下命令,即安装了最新版python
conda create -n csdn python
  • 实践表明,目前python3.12无法使用conda命令安装Jupyter(个人更倾向于使用conda安装,未测试pip命令)

更新conda(请忽略)

注意:如果更新千万千万千万不要中途停止!!!,个人建议不要更新
  创建conda虚拟环境时,如果提示:

Collecting package metadata (current_repodata.json): done
Solving environment: done


==> WARNING: A newer version of conda exists. <==
  current version: 23.7.2
  latest version: 23.9.0

Please update conda by running

    $ conda update -n base -c defaults conda

Or to minimize the number of packages updated during conda update use

     conda install conda=23.9.0

  当前使用的Conda版本为23.7.2,而最新版本是23.9.0。建议你通过运行以下命令来更新Conda:

conda update -n base -c defaults conda

  或者,如果你想在更新Conda时减少更新的软件包数量,可以使用以下命令:

conda install conda=23.9.0
中途停止的下场

在这里插入图片描述
  conda错乱了……

2. PyCharm使用conda环境

在这里插入图片描述

在这里插入图片描述
在这里插入图片描述
  结束上述操作后,环境变为csdn
在这里插入图片描述

3. Jupyter自启动

运行.ipynb文件

在这里插入图片描述

  尚未安装Jupyter~那肯定会运行失败,如图:

在这里插入图片描述

安装Jupyter(PyCharm自动安装)

  上述添加canda环境操作结束后,重启PyCharm,自动检测出Jupyter未安装,点击右侧安装Jupyter即可
在这里插入图片描述
  等待安装结束即可:
在这里插入图片描述

报错1. conda错乱

  更新conda中途停止的下场:
在这里插入图片描述

conda activate E:\Software\anaconda3\envs\csdn
E:\Software\anaconda3\condabin\conda.bat install -p E:/Software/anaconda3/envs/csdn jupyter -y

安装Jupyter(命令行)

报错2. python最新版安装失败

  额……python最新版3.12使用conda命令安装时等待n久,此题无解,不要使用最新版python
(可以尝试pip安装,这里未进行测试)

Collecting package metadata (current_repodata.json): done
Solving environment: failed with initial frozen solve. Retrying with flexible solve.
Solving environment: failed with repodata from current_repodata.json, will retry with next repodata source.
Collecting package metadata (repodata.json): done
Solving environment: \

conda create -n csdn1 python==3.10
conda activate csdn1
conda install jupyter

在这里插入图片描述

重运行.ipynb文件

在这里插入图片描述
successful

  • 29
    点赞
  • 87
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 4
    评论
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

QomolangmaH

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值