咱們已經將 TensorFlow 二進制文件上傳到了 PyPI,所以你能夠經過 pip 安裝, REQUIRED_PACKAGES section of setup.py 文件列出了 pip 將要安裝或升級的包。html
要安裝 TensorFlow,你的系統必須依據安裝瞭如下任一 Python 版本:python
若是你的系統尚未安裝符合以上版本的 Python,如今安裝。git
安裝 Python,你可能須要禁用系統完整性保護(SIP)來得到從 Mac App Store 外安裝軟件的許可。github
Pip 安裝和管理 Python寫的軟件包,若是你要使用本地 pip 安裝,系統上必須安裝下面的任一 pip 版本:shell
pip
, for Python 2.7pip3
, for Python 3.n.pip 或者 pip3 可能在你安裝 Python 的時候已經安裝了,執行如下任一命令確認系統上是否安裝了 pip 或 pip3:api
$ pip -V # for Python 2.7 $ pip3 -V # for Python 3.n
咱們強烈建議使用 pip 或者 pip3 爲 8.1 或者更新的版本安裝 TensorFlow,若是沒有安裝,執行如下任一命令安裝或更新:ruby
$ sudo easy_install --upgrade pip $ sudo easy_install --upgrade six
假設你的 Mac 上已經裝好了必備的程序,按照如下步驟執行:python2.7
shell $ pip install tensorflow # Python 2.7; CPU support $ pip3 install tensorflow # Python 3.n; CPU support
ui
若是上面的命令執行完成,如今能夠驗證你的安裝了。google
shell $ sudo pip install --upgrade tfBinaryURL # Python 2.7 $ sudo pip3 install --upgrade tfBinaryURL # Python 3.n
tfBinaryURL 是 Tensorflow 包的 URL,準確的 tfBinaryURL 值因操做系統和 Python 版本而異,在這裏找到和你係統相關的 tfBinaryURL 值。例如,你要在 Mac OS X 上安裝 Python 2.7 對應的 Tensorflow 版本,在虛擬環境中安裝 Tensorflow 就執行下面的命令:
shell $ sudo pip3 install --upgrade \ https://storage.googleapis.com/tensorflow/mac/cpu/tensorflow-1.2.1-py2-none-any.whl
DEPRECATION: Uninstalling a distutils installed project (six) has been deprecated and will be removed in a future version. This is due to the fact that uninstalling a distutils project will only partially uninstall the project.
Uninstalling six-1.4.1:
Exception:
Traceback (most recent call last):
File "/Library/Python/2.7/site-packages/pip/basecommand.py", line 215, in main
status = self.run(options, args)
File "/Library/Python/2.7/site-packages/pip/commands/install.py", line 342, in run
prefix=options.prefix_path,
File "/Library/Python/2.7/site-packages/pip/req/req_set.py", line 778, in install
requirement.uninstall(auto_confirm=True)
File "/Library/Python/2.7/site-packages/pip/req/req_install.py", line 754, in uninstall
paths_to_remove.remove(auto_confirm)
File "/Library/Python/2.7/site-packages/pip/req/req_uninstall.py", line 115, in remove
renames(path, new_path)
File "/Library/Python/2.7/site-packages/pip/utils/__init__.py", line 267, in renames
shutil.move(old, new)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py", line 302, in move
copy2(src, real_dst)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py", line 131, in copy2
copystat(src, dst)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py", line 103, in copystat
os.chflags(dst, st.st_flags)
OSError: [Errno 1] Operation not permitted: '/tmp/pip-mUKyli-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/six-1.4.1-py2.7.egg-info'
sudo pip install --upgrade --ignore-installed six
DEPRECATION: Uninstalling a distutils installed project (numpy) has been deprecated and will be removed in a future version. This is due to the fact that uninstalling a distutils project will only partially uninstall the project.
Exception:
Traceback (most recent call last):
File "/Library/Python/2.7/site-packages/pip/basecommand.py", line 215, in main
status = self.run(options, args)
File "/Library/Python/2.7/site-packages/pip/commands/install.py", line 342, in run
prefix=options.prefix_path,
File "/Library/Python/2.7/site-packages/pip/req/req_set.py", line 778, in install
requirement.uninstall(auto_confirm=True)
File "/Library/Python/2.7/site-packages/pip/req/req_install.py", line 754, in uninstall
paths_to_remove.remove(auto_confirm)
File "/Library/Python/2.7/site-packages/pip/req/req_uninstall.py", line 115, in remove
renames(path, new_path)
File "/Library/Python/2.7/site-packages/pip/utils/__init__.py", line 267, in renames
shutil.move(old, new)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py", line 302, in move
copy2(src, real_dst)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py", line 131, in copy2
copystat(src, dst)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/shutil.py", line 103, in copystat
os.chflags(dst, st.st_flags)
OSError: [Errno 1] Operation not permitted: '/tmp/pip-I9uezC-uninstall/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/numpy-1.8.0rc1-py2.7.egg-info'
sudo pip install --upgrade --ignore-installed numpy