Anaconda虚拟环境下安装tensorflow
查看已有虚拟环境:conda env list
- 创建环境 conda create --name tensorflow2.0 python==3.7
– 激活环境:active tensorflow2.0 退出环境:deactivate tensorflow2.0 - 安装相关软件包
pip install numpy matplotlib Pillow scikit-learn pandas -i https://pypi.tuna.tsinghua.edu.cn/simple
- 安装tensorflow
pip --default-timeout=100 install tensorflow -i https://pypi.tuna.tsinghua.edu.cn/simple
- 测试安装是否成功
打开python交互模式 import tensorflow
如果当前虚拟环境没有jupyter notebook,会调用base环境下的j.
虚拟环境下安装jupyter notebook及其初始配置。
- conda install ipython
- conda install jupyter
更改jupyter notebook的默认文件打开位置 :
- jupyter notebook --generate-config,会生成对应的配置文件,在配置文件.py里修改属性 c.NotebookApp.notebook_dir = ’ ’ ,在引号里写想要打开的位置 。
- 在快捷打开方式里把属性目标里的%HOMEPATH%删掉。(友情提示文件属性目标有文字限制 大概在270字个左右,所以起虚拟环境名字的时候要写短一点)
jupyter notebook可以安装插件 安装Nbextensions插件,可在jupyter notebook的终端页面输入
pip install jupyter_contrib_nbextensions
如果jupyter notebook没有tab键补全的功能,可以尝试将jedi版本从0.18.0降至0.17.2。
- pip install jedi==0.17.2