【吳恩達課程使用】anaconda (python 3.7) win10安裝 tensorflow 1.8
目前tensorflow是只支持到python3.6的,anaconda最新版本已經到python3.7。因為吳恩達課程比較舊一些,這里就配置更加穩定的win10+python3.5+tensorflow1.8版本。
一、國內鏡像源配置
https://mirror.tuna.tsinghua.edu.cn/help/anaconda/
各系統都可以通過修改用戶目錄下的 .condarc
文件:
channels:
- defaults
show_channel_urls: true
default_channels:
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/r
custom_channels:
conda-forge: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
msys2: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
bioconda: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
menpo: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
pytorch: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
simpleitk: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
即可添加 Anaconda Python 免費倉庫。Windows 用戶無法直接創建名為 .condarc
的文件,可先執行 conda config --set show_channel_urls yes
生成該文件之后再修改。
二、虛擬環境安裝
1.安裝anaconda3並在開始菜單打開Anaconda Prompt
2.執行命令:
conda create --name tensorflow10 python=3.5
3.當詢問是否執行時,輸入y(yes)
成功后:
4.執行命令
conda activate tensorflow10
即可進入tensorflow10環境。
在tensorflow10環境下執行命令
pip install tensorflow==1.8.0
三、jupyter notebook的相關配置
1.首先激活對應的conda環境
conda activate tensorflow10
2.將環境寫入notebook的kernel中
python -m ipykernel install --user --name tensorflow10 --display-name "Python (tensorflow10)"
如果沒有安裝ipykernel會報錯:
D:\Anaconda3\envs\python35\python.exe: No module named ipykernel
這時需要安裝ipykernel,執行命令:
conda install ipykernel
3.在系統內切換
jupyter會出現 import error win32api 錯誤,解決:
pip install pypiwin32
之后就可以在jupyter內直接切換了: