首页 > 其他分享 >jupyter notebook初步以及conda虚拟环境创建

jupyter notebook初步以及conda虚拟环境创建

时间:2022-12-18 10:45:30浏览次数:55  
标签:jupyter cn notebook 虚拟环境 conda tsinghua https edu

发现jupyter是个好东西,但是初步设置有点麻烦,记录一下

这里用的是anaconda3自带的

  • 修改jupyter默认目录

默认目录在C盘,不想让C盘爆炸的话肯定是要改一下的

提前建好一个新目录,例如:X:\jupyter

在cmd窗口中输入:

jupyter notebook --generate-config

得到配置文件的地址,找到并用记事本打开,搜索“notebook_dir”

把注释删掉,改为:c.NotebookApp.notebook_dir = 'X:\jupyter'

保存配置文件,找到开始菜单里jupyter的快捷方式所在位置,打开属性,把.py后面一串字符删掉

重新打开jupyter,应该就是新的空目录了

中间可能会出现多冒出来一个jupyter快捷方式,删掉就行

  • 关联环境和包

管理员打开cmd,输入:

conda install nb_conda

如果没报错,恭喜你,但是大概率会出现以下错误:

Solving evironment: failed with initial frozen solve. Retrying with flexible solve.

解决方法:

更新anaconda:

conda update --prefix X:\Anaconda anaconda

其中X:\Anaconda是你的安装目录

删除原镜像:

conda config --remove-key channels

添加清华源:

conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/msys2/

然后重新install,问题解决,重新打开jupyter能看到多了一个conda选项卡

  • 新建tensorflow独立环境

创建一个名为tensorflow2.4的环境并激活:

conda create -n tensorflow2.4 python==3.8
conda activate tensorflow2.4

安装依赖包和tensorflow2.4:

pip install numpy==1.19.5 matplotlib Pillow scikit-learn pandas==1.3.4 -i https://pypi.tuna.tsinghua.edu.cn/simple
pip install tensorflow==2.4.0 -i https://pypi.tuna.tsinghua.edu.cn/simple

安装完成后进入python环境,输入:

import tensorflow

回显:

因为这台电脑没GPU,所以这样就算成功了

在当前环境里安装一下jupyter:

pip install jupyter -i https://pypi.tuna.tsinghua.edu.cn/simple

现在重新打开jupyter,在new选项里就能看到tensorflow2.4的环境了,万岁!

参考链接:

中国大学mooc:神经网络与深度学习——TensorFlow实践

https://blog.csdn.net/weixin_43821215/article/details/125960662

https://zhuanlan.zhihu.com/p/139776843

标签:jupyter,cn,notebook,虚拟环境,conda,tsinghua,https,edu
From: https://www.cnblogs.com/AntennaZ/p/16990011.html

相关文章