MAC OS系统下安装python3
在python官网下载安装包
检查python3、pip3、virtualenv是否已经安装
python3 --version
pip3 --version
virtualenv --version
安装virtualenv
sudo pip3 install -U virtualenv
Collecting virtualenv
Downloading https://files.pythonhosted.org/packages/7e/1b/6c00d57127608793e16e8b7f813e64d58a1938505c42fe190d1386ab41e1/virtualenv-16.4.0-py2.py3-none-any.whl (2.0MB)
100% |████████████████████████████████| 2.0MB 54kB/s
Installing collected packages: virtualenv
Successfully installed virtualenv-16.4.0
You are using pip version 10.0.1, however version 19.0.2 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
升级pip3
sudo pip3 install --upgrade pip
Collecting pip
Downloading https://files.pythonhosted.org/packages/d7/41/34dd96bd33958e52cb4da2f1bf0818e396514fd4f4725a79199564cd0c20/pip-19.0.2-py2.py3-none-any.whl (1.4MB)
100% |████████████████████████████████| 1.4MB 36kB/s
Installing collected packages: pip
Found existing installation: pip 10.0.1
Uninstalling pip-10.0.1:
Successfully uninstalled pip-10.0.1
Successfully installed pip-19.0.2
使用虚拟环境安装tensorflow
新建一个虚拟环境放在当前目录下的venv目录下
virtualenv --system-site-packages -p python3 ./venv
激活虚拟环境
source ./venv/bin/activate
退出虚拟环境
deactivate
安装tensorflow
pip3 install --upgrade tensorflow
Collecting tensorflow
Downloading https://files.pythonhosted.org/packages/81/07/be624c7e0a63b080a76b7f6faf417eecdc5f6480f6a740a8bcf8991bce0b/tensorflow-1.12.0-cp36-cp36m-macosx_10_11_x86_64.whl (62.0MB)
100% |████████████████████████████████| 62.0MB 33kB/s
Collecting termcolor>=1.1.0 (from tensorflow)
Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ReadTimeoutError("HTTPSConnectionPool(host='pypi.org', port=443): Read timed out. (read timeout=15)",)': /simple/termcolor/
Downloading https://files.pythonhosted.org/packages/8a/48/a76be51647d0eb9f10e2a4511bf3ffb8cc1e6b14e9e4fab46173aa79f981/termcolor-1.1.0.tar.gz
Collecting keras-applications>=1.0.6 (from tensorflow)
Downloading https://files.pythonhosted.org/packages/90/85/64c82949765cfb246bbdaf5aca2d55f400f792655927a017710a78445def/Keras_Applications-1.0.7-py2.py3-none-any.whl (51kB)
100% |████████████████████████████████| 61kB 42kB/s
Collecting astor>=0.6.0 (from tensorflow)
Downloading https://files.pythonhosted.org/packages/35/6b/11530768cac581a12952a2aad00e1526b89d242d0b9f59534ef6e6a1752f/astor-0.7.1-py2.py3-none-any.whl
Collecting absl-py>=0.1.6 (from tensorflow)
Downloading https://files.pythonhosted.org/packages/31/bc/ab68120d1d89ae23b694a55fe2aece2f91194313b71f9b05a80b32d3c24b/absl-py-0.7.0.tar.gz (96kB)
100% |████████████████████████████████| 102kB 32kB/s
Collecting numpy>=1.13.3 (from tensorflow)
Downloading https://files.pythonhosted.org/packages/88/b8/569d9c702685b595812fbfd9ee04f240653b7a15feec43cc98be3b34e5f5/numpy-1.16.1-cp36-cp36m-macosx_10_6_intel.macosx_10_9_intel.macosx_10_9_x86_64.macosx_10_10_intel.macosx_10_10_x86_64.whl (13.9MB)
100% |████████████████████████████████| 13.9MB 22kB/s
Collecting gast>=0.2.0 (from tensorflow)
Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ReadTimeoutError("HTTPSConnectionPool(host='pypi.org', port=443): Read timed out. (read timeout=15)",)': /simple/gast/
Downloading https://files.pythonhosted.org/packages/4e/35/11749bf99b2d4e3cceb4d55ca22590b0d7c2c62b9de38ac4a4a7f4687421/gast-0.2.2.tar.gz
Requirement already satisfied, skipping upgrade: six>=1.10.0 in /Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages (from tensorflow) (1.11.0)
Requirement already satisfied, skipping upgrade: wheel>=0.26 in ./venv_ai/lib/python3.6/site-packages (from tensorflow) (0.33.0)
Collecting keras-preprocessing>=1.0.5 (from tensorflow)
Downloading https://files.pythonhosted.org/packages/c0/bf/0315ef6a9fd3fc2346e85b0ff1f5f83ca17073f2c31ac719ab2e4da0d4a3/Keras_Preprocessing-1.0.9-py2.py3-none-any.whl (59kB)
100% |████████████████████████████████| 61kB 23kB/s
Collecting grpcio>=1.8.6 (from tensorflow)
Downloading https://files.pythonhosted.org/packages/50/11/e1a1e4912131c783f01734597150a58d75003d89aeff3ebf3d2ee5b4d36a/grpcio-1.18.0-cp36-cp36m-macosx_10_9_x86_64.whl (1.8MB)
100% |████████████████████████████████| 1.8MB 34kB/s
Collecting protobuf>=3.6.1 (from tensorflow)
Downloading https://files.pythonhosted.org/packages/c7/27/133f225035b9539f2dcfebcdf9a69ff0152f56e0120160ec5c972ea7deb9/protobuf-3.6.1-cp36-cp36m-macosx_10_6_intel.macosx_10_9_intel.macosx_10_9_x86_64.macosx_10_10_intel.macosx_10_10_x86_64.whl (1.2MB)
100% |████████████████████████████████| 1.2MB 24kB/s
Collecting tensorboard<1.13.0,>=1.12.0 (from tensorflow)
Downloading https://files.pythonhosted.org/packages/07/53/8d32ce9471c18f8d99028b7cef2e5b39ea8765bd7ef250ca05b490880971/tensorboard-1.12.2-py3-none-any.whl (3.0MB)
100% |████████████████████████████████| 3.1MB 18kB/s
Collecting h5py (from keras-applications>=1.0.6->tensorflow)
Downloading https://files.pythonhosted.org/packages/03/21/1cdf7fa7868528b35c1a08a770eb9334279574a8b5f1d7a2966dcec14e42/h5py-2.9.0-cp36-cp36m-macosx_10_6_intel.macosx_10_9_intel.macosx_10_9_x86_64.macosx_10_10_intel.macosx_10_10_x86_64.whl (6.3MB)
100% |████████████████████████████████| 6.3MB 10kB/s
Requirement already satisfied, skipping upgrade: setuptools in ./venv_ai/lib/python3.6/site-packages (from protobuf>=3.6.1->tensorflow) (40.8.0)
Collecting markdown>=2.6.8 (from tensorboard<1.13.0,>=1.12.0->tensorflow)
Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ReadTimeoutError("HTTPSConnectionPool(host='pypi.org', port=443): Read timed out. (read timeout=15)",)': /simple/markdown/
Downloading https://files.pythonhosted.org/packages/7a/6b/5600647404ba15545ec37d2f7f58844d690baf2f81f3a60b862e48f29287/Markdown-3.0.1-py2.py3-none-any.whl (89kB)
100% |████████████████████████████████| 92kB 20kB/s
Collecting werkzeug>=0.11.10 (from tensorboard<1.13.0,>=1.12.0->tensorflow)
Downloading https://files.pythonhosted.org/packages/20/c4/12e3e56473e52375aa29c4764e70d1b8f3efa6682bef8d0aae04fe335243/Werkzeug-0.14.1-py2.py3-none-any.whl (322kB)
100% |████████████████████████████████| 327kB 19kB/s
Installing collected packages: termcolor, numpy, h5py, keras-applications, astor, absl-py, gast, keras-preprocessing, grpcio, protobuf, markdown, werkzeug, tensorboard, tensorflow
Running setup.py install for termcolor ... done
Running setup.py install for absl-py ... done
Running setup.py install for gast ... done
Successfully installed absl-py-0.7.0 astor-0.7.1 gast-0.2.2 grpcio-1.18.0 h5py-2.9.0 keras-applications-1.0.7 keras-preprocessing-1.0.9 markdown-3.0.1 numpy-1.16.1 protobuf-3.6.1 tensorboard-1.12.2 tensorflow-1.12.0 termcolor-1.1.0 werkzeug-0.14.1
验证是否安装成功
python3 -c "import tensorflow as tf; tf.enable_eager_execution(); print(tf.reduce_sum(tf.random_normal([1000, 1000])))"
输出:tf.Tensor(-303.03473, shape=(), dtype=float32)
评论列表(0条)