在新conda环境tf中无法启动Jupyter Notebook的问题咨询
Jupyter Notebook无法启动问题的原因及解决
我创建了名为tf的TensorFlow conda环境,环境可正常使用,但执行以下安装步骤运行Jupyter Notebook时出现问题:
conda install ipykernel (执行成功) python -m ipykernel install --user --name=tf (执行成功) jupyter notebook (执行报错)
执行jupyter命令返回:
(tf) C:\Users\Anonymous>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 options: -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: kernel kernelspec migrate run script troubleshoot Please specify a subcommand or one of the optional arguments.
执行jupyter notebook命令返回:
(tf) C:\Users\Anonymous>jupyter notebook usage: jupyter [-h] [--version] [--config-dir] [--data-dir] [--runtime-dir] [--paths] [--json] [--debug] [subcommand] Jupyter: Interactive Computing positional arguments: subcommand the subcommand to launch options: -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: kernel kernelspec migrate run script troubleshoot Jupyter command `jupyter-notebook` not found.
问题原因
你只安装了ipykernel(用于让Jupyter识别conda环境作为运行内核),但没有在tf环境中安装Jupyter Notebook的核心程序,所以系统找不到jupyter-notebook命令,导致执行失败。
解决步骤
- 确保处于激活的
tf环境中:conda activate tf - 在
tf环境内安装Jupyter Notebook:
也可以用pip安装:conda install jupyter notebookpip install jupyter notebook - 安装完成后,重新执行
jupyter notebook即可正常启动。
补充说明
如果之前在base环境中安装过Jupyter,也可以直接从base环境启动Jupyter,然后在Notebook中选择tf内核运行代码,但这种方式可能存在路径依赖问题,不如直接在tf环境内安装Jupyter稳定。
内容的提问来源于stack exchange,提问作者Kim
相关产品推荐
相关产品推荐

