一、准备工作
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官网
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==
标签:Jupyter,--,conda,PyCharm,安装,dir From: https://blog.51cto.com/u_16363537/8463478