linux 环境下,在anaconda中创建虚拟环境,并安装tensorflow,配置jupyter的ikernel.
创建虚拟环境
查看现有的环境:
conda env list
创建名称为‘tensorflow’的虚拟环境:
conda create --name tensorflow
创建好后进入环境:
source activate tensorflow
可以看到前面有一个(tensorflow),表示进入该环境。
安装tensorflow
在tensorflow环境下下载tensorflow2.0
pip3 install -i
https://pypi.tuna.tsinghua.edu.cn/simple tensorflow==2.0.0
系统会自动匹配对应的python版本.
安装时遇到的问题
(1)ERROR: Cannot uninstall ‘wrapt’. It is a distutils installed project and thus we cannot accurately 。。。。
解决方法:
pip3 install -U
--ignore-installed wrapt enum34 simplejson netaddr
(2)ERROR: tensorboard 1.14.0 has requirement setuptools>=41.0.0, but you’ll have setuptools 39.1.0 which is incompatible.
解决方法
pip3 install -i
https://pypi.tuna.tsinghua.edu.cn/simple setuptools==41.0.0
解决完上述问题,重新安装tensorflow,安装成功
安装keras
pip3 install -i
https://pypi.tuna.tsinghua.edu.cn/simple keras
配置jupyter kernel
进入到tensorflow环境中
source activate tensorflow
查看现在安装的内核和位置
jupyter kernelspec list
安装ipykernel
python3 -m pip install ipykernel
定义一个名字为tensorflow的kernel
python3 -m ipykernel install --user --name tensorflow
--display-name "tensorflow"
再次查看对应的kernel:
配置完成
退出tensorflow环境
conda deactivate
删除kernel
删除上面定义的tensorflow kernel
jupyter kernelspec remove tensorflow
删除定义的tensorflow环境
conda remove –n tensorflow --all
参考文档:
https://www.cnblogs.com/conver/p/11141176.html
https://blog.csdn.net/weixin_40040107/article/details/102766474
https://blog.csdn.net/hohaizx/article/details/89633203