天天看點

python之路安裝Anaconda安裝TensorFlow檢測tf

安裝Anaconda

安裝Anaconda後配置環境變量

系統變量Path加上D:\Anaconda3;D:\Anaconda3\Scripts;D:\Anaconda3\Library\bin

cmd中判斷,嘿嘿安裝好了python和numpy。

python之路安裝Anaconda安裝TensorFlow檢測tf

在Spyder裡用代碼檢測:

from skimage import io
img = io.imread('C:/Users/YOGA/Desktop/1.png')
io.imshow(img)
           

最後在console方框裡顯示(可能壓縮了?):

python之路安裝Anaconda安裝TensorFlow檢測tf

安裝TensorFlow

python版本是37的巨麻煩,網上一般的教程都是36 35,還有說隻支援35的,不清楚。。。

  1. conda create -n tensorflow python=3.7建立一個TensorFlow的環境,然後conda activate tensorflow,激活環境。
  2. 通過這個連結https://pypi.org/project/tensorflow/#files下載下傳到一個檔案夾中。
  3. cmd進入檔案夾,“pip install -i https://pypi.tuna.tsinghua.edu.cn/simple/ --upgrade tensorflow-2.0.0-cp37-cp37m-win_amd64.whl”,其中連結是清華鏡像,可改成其他路徑。(pip install的話下載下傳速度太慢,超過時間會報錯)

阿裡雲 http://mirrors.aliyun.com/pypi/simple/

中國科技大學 https://pypi.mirrors.ustc.edu.cn/simple/

豆瓣(douban) http://pypi.douban.com/simple/

清華大學 https://pypi.tuna.tsinghua.edu.cn/simple/

中國科學技術大學 http://pypi.mirrors.ustc.edu.cn/simple/

檢測tf

因為裝的是tf2.0版本,指令更新了,輸入下列代碼,若輸出‘Hello,TensorFlow!’則已經安裝成功嘻嘻

import tensorflow as tf
tf.compat.v1.disable_eager_execution()
hello = tf.constant('Hello, TensorFlow!')
sess = tf.compat.v1.Session()
print(sess.run(hello))