在Mac OS X上安裝TensorFlow

2021-07-29 12:47:39 字數 1697 閱讀 8174

sudo easy_install pip
如果這部出現錯誤,可以看看自己/usr/bin/ 目錄是否有多個版本的

easy_install,比如說我就有三個,可以試試換個

easy_install版本試試,當時用easy_install時遇到錯誤了,後面換成easy_install-2.7就好了

virtualenv --system-site-packages targetdirectory
把virtualenv環境放在targetdirectory,這個目錄可以自己建立的,名字看你自己愛好了,比如我的targetdirectory是 「

~/desktop/python/tensorflow/」

$ source ~/tensorflow/bin/activate      # if using bash, sh, ksh, or zsh

$ source ~/tensorflow/bin/activate.csh # if using csh or tcsh

如果想釋放當前環境直接執行deactivate就行

$ pip install --upgrade tensorflow # for python 2.7

$ pip3 install --upgrade tensorflow # for python 3.n

$ pip install --upgrade tensorflow-gpu # for python 2.7 and gpu

$ pip3 install --upgrade tensorflow-gpu # for python 3.n and gpu

可以根據自己的需求安裝,此處我安裝的是第乙個

如果你想解除安裝tensorflow,直接刪除上面建立的targetdirectory就行

$ rm -r your_targetdirectory
開啟乙個終端,通過步驟4啟用環境,在terminal輸入python,在互動式的shell視窗輸入下面簡單的程式

>>> import tensorflow as tf

>>> hello = tf.constant('hello, tensorflow!')

>>> sess = tf.session()

>>> print(sess.run(hello))

如果你看到下面的輸出就表示安裝成功了,可以開始學習tensorflow了

hello, tensorflow!
下圖是我從啟用環境到執行程式的截圖

執行exit()是退出python,deactivate是退出tensorflow環境,到這查不多就可以繼續後續的學習了。如果你想通過其他方式安裝,可以去官網檢視 裡面提供了不同作業系統的的不同安裝方式,檢視前先準備好梯子。

在windows上安裝CPU版Tensorflow

一 安裝環境 windows 64位 python3.5 二 安裝步驟 安裝時勾選add python to path 3.開啟控制台 快捷方式 win r 後輸入cmd pip install tensorflowinstall時自動檢測安裝依賴項,安裝結束後如下圖 三 檢測安裝是否成功 impo...

在Mac OS X上安裝 Ruby執行環境

對於新入門的開發者,如何安裝 ruby和ruby gems 的執行環境可能會是個問題,本頁主要介紹如何用一條靠譜的路子快速安裝 ruby 開發環境。此安裝方法同樣適用於產品環境!系統需求 首先確定作業系統環境,不建議在 windows 上面搞,所以你需要用 mac os x 任意 linux 發行版...

在Mac OS X上安裝 Ruby執行環境

安裝cocoapods的順序 homebrew ruby cocoapods 步驟1 安裝 rvm ruby version manager curl l bash s stable 在執行過程中可能會遇到以下提示 自動安裝homebrew 如果沒有輸入enter,則無法安裝在預設路徑下。about...