原文鏈接:http://www.cnblogs.com/tensorflownews/p/7298646.html
Mac 使用本地 pip 安裝Tensorflow
我們已經將 TensorFlow 二進制文件上傳到了 PyPI,因此你可以通過 pip 安裝, REQUIRED_PACKAGES section of setup.py 文件列出了 pip 將要安裝或升級的包。
必備: Python
要安裝 TensorFlow,你的系統必須依據安裝了以下任一 Python 版本:
- Python 2.7,建議首先更新最新的Python2.7,我使用的是Python2.7,點擊這里下載最新版
- Python 3.3+
如果你的系統還沒有安裝符合以上版本的 Python,現在安裝。
安裝 Python,你可能需要禁用系統完整性保護(SIP)來獲得從 Mac App Store 外安裝軟件的許可。
必備: pip
Pip 安裝和管理 Python寫的軟件包,如果你要使用本地 pip 安裝,系統上必須安裝下面的任一 pip 版本:
pip
, for Python 2.7pip3
, for Python 3.n.
pip 或者 pip3 可能在你安裝 Python 的時候已經安裝了,執行以下任一命令確認系統上是否安裝了 pip 或 pip3:
$ pip -V # for Python 2.7 $ pip3 -V # for Python 3.n
我們強烈建議使用 pip 或者 pip3 為 8.1 或者更新的版本安裝 TensorFlow,如果沒有安裝,執行以下任一命令安裝或更新:
$ sudo easy_install --upgrade pip $ sudo easy_install --upgrade six
安裝 TensorFlow
假設你的 Mac 上已經裝好了必備的程序,按照以下步驟執行:
- 執行以下任一命令安裝 TensorFlow:
shell $ pip install tensorflow # Python 2.7; CPU support $ pip3 install tensorflow # Python 3.n; CPU support
如果上面的命令執行完成,現在可以驗證你的安裝了。
- (可選的) 如果步驟 1 失敗了,執行下面的命令安裝最新版本 TensorFlow:
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
Exception
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