【2023最新版】PyCharm使用 Jupyter Notebook详解(在conda环境里安装Jupyter~PyCharm使用conda环境~Jupyter自启动)
  ZjJ0fRereH8S 2023年11月19日 89 0

一、准备工作

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

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==

【版权声明】本文内容来自摩杜云社区用户原创、第三方投稿、转载,内容版权归原作者所有。本网站的目的在于传递更多信息,不拥有版权,亦不承担相应法律责任。如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱: cloudbbs@moduyun.com

  1. 分享:
最后一次编辑于 2023年11月19日 0

暂无评论

推荐阅读
ZjJ0fRereH8S