<前提条件和准备工作>
本地运行编程练习的环境部署,我是选择在windows上运行:
1. 首先下载安装 Python 3.7 版本的 Anaconda(教程中说的是3.6版本,但是现在已经更新到3.7)
更新:试了一下如果使用3.7版本的python没有办法安装tenserflow的包,因为现在在清华镜像站中最新的tensorflow包不支持3.7版本,所以还是需要使用3.6版本,按照教程中写的。可以使用Anaconda官网上的教程来进行版本升级或者另外部署一个python环境。
2. 然后在Anaconda Prompt中输入以下命令,安装软件包和部署环境,其中有几个命令
(base) C:\>conda create -n mlcc pip python=3.7 //需要把版本修改为当前最新版本3.7,如果用3.6会报错
Solving environment: done //运行结果
## Package Plan ##
environment location: C:\Users\nalei10\AppData\Local\Continuum\anaconda3\envs\mlcc
added / updated specs:
- pip
- python=3.7
The following packages will be downloaded:
package | build
---------------------------|-----------------
setuptools-40.6.2 | py37_0 654 KB
pip-18.1 | py37_0 1.8 MB
openssl-1.1.1a | he774522_0 5.7 MB
sqlite-3.25.3 | he774522_0 937 KB
python-3.7.1 | h8c8aaf0_6 17.7 MB
wheel-0.32.3 | py37_0 53 KB
certifi-2018.11.29 | py37_0 146 KB
------------------------------------------------------------
Total: 27.0 MB
The following NEW packages will be INSTALLED:
ca-certificates: 2018.03.07-0
certifi: 2018.11.29-py37_0
openssl: 1.1.1a-he774522_0
pip: 18.1-py37_0
python: 3.7.1-h8c8aaf0_6
setuptools: 40.6.2-py37_0
sqlite: 3.25.3-he774522_0
vc: 14.1-h0510ff6_4
vs2015_runtime: 14.15.26706-h3a45250_0
wheel: 0.32.3-py37_0
wincertstore: 0.2-py37_0
Proceed ([y]/n)? y
Downloading and Extracting Packages
setuptools-40.6.2 | 654 KB | ############################################################################ | 100%
pip-18.1 | 1.8 MB | ############################################################################ | 100%
openssl-1.1.1a | 5.7 MB | ############################################################################ | 100%
sqlite-3.25.3 | 937 KB | ############################################################################ | 100%
python-3.7.1 | 17.7 MB | ############################################################################ | 100%
wheel-0.32.3 | 53 KB | ############################################################################ | 100%
certifi-2018.11.29 | 146 KB | ############################################################################ | 100%
Preparing transaction: done
Verifying transaction: done
Executing transaction: done
#
# To activate this environment, use
#
# $ conda activate mlcc
#
# To deactivate an active environment, use
#
# $ conda deactivate
(base) C:\>conda activate mlcc //激活环境
(mlcc) C:\>pip install -i https://pypi.tuna.tsinghua.edu.cn/simple --ignore-installed --upgrade tensorflow matplotlib pandas sklearn scipy seaborn //下一步如果按照教程中的命令会报错,所以改成现在这样
Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple
Collecting tensorflow
Could not find a version that satisfies the requirement tensorflow (from versions: )
No matching distribution found for tensorflow //tensorflow安装报错,我理解是当前版本已经是最新版了,欢迎指正
更新:上面的理解是错误的,应该是不支持3.7版本的python
(mlcc) C:\>pip install -i https://pypi.tuna.tsinghua.edu.cn/simple --ignore-installed --upgrade matplotlib pandas sklearn scipy seaborn //去掉tensorflow,安装其他的可安装包
Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple //运行结果参考
Collecting matplotlib
Downloading https://pypi.tuna.tsinghua.edu.cn/packages/5c/ee/efaf04efc763709f6840cd8d08865d194f7453f43e98d042c92755cdddec/matplotlib-3.0.2-cp37-cp37m-win_amd64.whl (8.9MB)
100% |████████████████████████████████| 8.9MB 87kB/s
Collecting pandas
Downloading https://pypi.tuna.tsinghua.edu.cn/packages/58/a8/03e5fe0edbc522e46cb27df2abfb4266814129253d8462f38bc704a76a2a/pandas-0.23.4-cp37-cp37m-win_amd64.whl (7.9MB)
100% |████████████████████████████████| 7.9MB 42kB/s
Collecting sklearn
Downloading https://pypi.tuna.tsinghua.edu.cn/packages/1e/7a/dbb3be0ce9bd5c8b7e3d87328e79063f8b263b2b1bfa4774cb1147bfcd3f/sklearn-0.0.tar.gz
Collecting scipy
Downloading https://pypi.tuna.tsinghua.edu.cn/packages/c4/f3/752fd6778a9d07fddb2b02dac5895287e594d2d0d156a2a422c710f6a851/scipy-1.1.0-cp37-none-win_amd64.whl (30.9MB)
100% |████████████████████████████████| 30.9MB 76kB/s
Collecting seaborn
Downloading https://pypi.tuna.tsinghua.edu.cn/packages/a8/76/220ba4420459d9c4c9c9587c6ce607bf56c25b3d3d2de62056efe482dadc/seaborn-0.9.0-py3-none-any.whl (208kB)
100% |████████████████████████████████| 215kB 71kB/s
Collecting numpy>=1.10.0 (from matplotlib)
Downloading https://pypi.tuna.tsinghua.edu.cn/packages/00/0e/5a8c34adb97fc1cd6636d78050e575945e874c8516d501421d5a0f377a6c/numpy-1.15.4-cp37-none-win_amd64.whl (13.5MB)
100% |████████████████████████████████| 13.5MB 67kB/s
Collecting python-dateutil>=2.1 (from matplotlib)
Downloading https://pypi.tuna.tsinghua.edu.cn/packages/74/68/d87d9b36af36f44254a8d512cbfc48369103a3b9e474be9bdfe536abfc45/python_dateutil-2.7.5-py2.py3-none-any.whl (225kB)
100% |████████████████████████████████| 235kB 37kB/s
Collecting kiwisolver>=1.0.1 (from matplotlib)
Downloading https://pypi.tuna.tsinghua.edu.cn/packages/7c/be/7ae355b45699460e369ebf88d86058fca26827933974cc3f6b6b7800a324/kiwisolver-1.0.1-cp37-none-win_amd64.whl (57kB)
100% |████████████████████████████████| 61kB 64kB/s
Collecting cycler>=0.10 (from matplotlib)
Downloading https://pypi.tuna.tsinghua.edu.cn/packages/f7/d2/e07d3ebb2bd7af696440ce7e754c59dd546ffe1bbe732c8ab68b9c834e61/cycler-0.10.0-py2.py3-none-any.whl
Collecting pyparsing!=2.0.4,!=2.1.2,!=2.1.6,>=2.0.1 (from matplotlib)
Downloading https://pypi.tuna.tsinghua.edu.cn/packages/71/e8/6777f6624681c8b9701a8a0a5654f3eb56919a01a78e12bf3c73f5a3c714/pyparsing-2.3.0-py2.py3-none-any.whl (59kB)
100% |████████████████████████████████| 61kB 61kB/s
Collecting pytz>=2011k (from pandas)
Downloading https://pypi.tuna.tsinghua.edu.cn/packages/f8/0e/2365ddc010afb3d79147f1dd544e5ee24bf4ece58ab99b16fbb465ce6dc0/pytz-2018.7-py2.py3-none-any.whl (506kB)
100% |████████████████████████████████| 512kB 34kB/s
Collecting scikit-learn (from sklearn)
Downloading https://pypi.tuna.tsinghua.edu.cn/packages/74/fc/e3d24a3472e32102f9f667adf05a41fdd5b56893f34464f06c8549684cd5/scikit_learn-0.20.1-cp37-cp37m-win_amd64.whl (4.8MB)
100% |████████████████████████████████| 4.8MB 71kB/s
Collecting six>=1.5 (from python-dateutil>=2.1->matplotlib)
Downloading https://pypi.tuna.tsinghua.edu.cn/packages/73/fb/00a976f728d0d1fecfe898238ce23f502a721c0ac0ecfedb80e0d88c64e9/six-1.12.0-py2.py3-none-any.whl
Collecting setuptools (from kiwisolver>=1.0.1->matplotlib)
Downloading https://pypi.tuna.tsinghua.edu.cn/packages/37/06/754589caf971b0d2d48f151c2586f62902d93dc908e2fd9b9b9f6aa3c9dd/setuptools-40.6.3-py2.py3-none-any.whl (573kB)
100% |████████████████████████████████| 573kB 61kB/s
Building wheels for collected packages: sklearn
Running setup.py bdist_wheel for sklearn ... done
Stored in directory: C:\Users\nalei10\AppData\Local\pip\Cache\wheels\75\8b\b3\454457b26d41971ddb16026d1039e7d38708f173b246e9fd62
Successfully built sklearn
Installing collected packages: numpy, six, python-dateutil, setuptools, kiwisolver, cycler, pyparsing, matplotlib, pytz, pandas, scipy, scikit-learn, sklearn, seaborn
Successfully installed cycler-0.10.0 kiwisolver-1.0.1 matplotlib-3.0.2 numpy-1.15.4 pandas-0.23.4 pyparsing-2.3.0 python-dateutil-2.7.5 pytz-2018.7 scikit-learn-0.20.1 scipy-1.1.0 seaborn-0.9.0 setuptools-40.6.3 six-1.12.0 sklearn-0.0
第三步及以后就是按照教程中的步骤顺利进行
更新:按照教程步骤安装完成,并且可以运行成功tensorflow的hello world程序,之前运行的时候会报错找不到tensorflow模块