进入方式
- 这里使用anaconda自带的
Jupyter Netbook,虚拟环境默认是anaconda下的python3虚拟环境。

- cmd输入命令
jupyter notebook,进不进虚拟环境都可以。

配置自己的虚拟环境
参考博客,win+r打开cmd,进到虚拟环境中,直接依次运行:
conda install jupyter
conda install ipykernel # 安装jupyter内核
# 添加虚拟环境到jupyter中
python -m ipykernel install --user --name study1 --display-name study1_py38
#如果需要移除jupyter中的虚拟环境,用这个命令
jupyter kernelspec remove 环境名
关闭jupyter,再次运行,出现自己的环境名称study1_py38,成功:


运行jupyter,出现的一些错误
1.运行报错:ModuleNotFoundError: No module named 'keras'
但是我已经安装了keras。参考博客说是路径不对,打开Anaconda Prompt,运行下面的命令:
jupyter kernelspec list #查看当前的可用的kernel
jupyter kernelspec remove study1 #删除前面创建的kernel
activate study1 #进入虚拟环境
conda install ipykernel
python -m ipykernel install --name study1
jupyter notebook #打开jupyter

2. 报错:ImportError: cannot import name 'bmat' from 'scipy.sparse.sputils' (D:\anaconda3\envs\study1\lib\site-packages\scipy\sparse\sputils.py)
参考博客,可能是版本太高的问题,先找到可以安装的版本。
conda search scipy #查看可以安装的scipy版本
降低一个版本,先降低版本到1.7.3

发现tensorflow的依赖需要scipy==1.4.1运行下面的命令将这些版本调整下:
pip install scipy==1.4.1 --user
pip install gast==0.3.3 --user
pip install numpy==1.19.0 --user
pip install tensorflow-estimator==2.4.0 --user
jupyter notebook #打开jupyter
运行成功
jupyter创建ipynb文件,重命名

运行代码ctrl+enter

这篇博客介绍了如何在Windows环境下配置anaconda的Jupyter Notebook,包括创建和删除虚拟环境,安装与移除内核,以及解决运行时遇到的模块导入错误和scipy版本不兼容问题。通过降低scipy版本和重新安装相关库,最终成功运行jupyter并创建了ipynb文件。
2792

被折叠的 条评论
为什么被折叠?



