Tensorflow入门笔记【一】环境
1、傻瓜式集成環(huán)境anaconda安裝
(1)WINDOWS環(huán)境下,只能使用python3.5(64bit)
(2)暫時(shí)推薦Anoconda3-4.2.0-windows-x86_64。目前我是基于該版本學(xué)習(xí),其他版本沒有試過
https://mirrors.tuna.tsinghua.edu.cn/anaconda/archive/Anaconda3-4.2.0-Windows-x86_64.exe
【延伸:清華大學(xué)開源軟件鏡像站 使用技巧(待補(bǔ)充)】
2、tensorflow庫安裝
2.1 使用conda 安裝tensorflow
(1)使用管理員權(quán)限,打開anaconda prompt
(2)執(zhí)行conda install tensorflow。以下是正常安裝的提示
【注意:嘗試過其他anaconda版本下,執(zhí)行2.1-(2)的命令會(huì)出現(xiàn)我暫時(shí)不理解的錯(cuò)誤】
(3)【然而,最后還是因?yàn)榫W(wǎng)絡(luò)不好,所以沒能成功。】
2.2 使用清華鏡像源安裝tensorflow
(1)執(zhí)行如下命令,給conda的配置文件添加鏡像源路徑:
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
conda config?--add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
【注意】我的anaconda安裝在D盤(暫不清晰接下來描述的現(xiàn)象與此是否有關(guān)),執(zhí)行命令后提示如下錯(cuò)誤
顯然,配置文件的路徑為空。
錯(cuò)誤提示缺乏.condarc這個(gè)文件。應(yīng)該就是conda的config file了。
那么,自然的,去創(chuàng)建相應(yīng)的目錄和文件后再運(yùn)行
再次,運(yùn)營上述命令,不再報(bào)錯(cuò)。
(2)執(zhí)行config --set show_channel_urls yes
(3)執(zhí)行pip install -i https://pypi.tuna.tsinghua.edu.cn/simple tensorflow
【安裝成功。提示信息見最末尾附錄一】
3、測試tensorflow是否安裝成功
(1)打開Jupiter Notebook,看到如下命令行窗口彈出后,耐心等待(因設(shè)備性能差異,窗口彈出后可能會(huì)出現(xiàn)沒有任何打印信息的情況,我的設(shè)備目前是約15s左右,出現(xiàn)如下打印信息,就會(huì)彈出web應(yīng)用);
(2)Jupyter Notebook在瀏覽器打開,其默認(rèn)文件存儲(chǔ)路徑為C盤【我的文檔】
(3)如下窗口所示,新建python[conda root],文件中輸入“import tensorflow”后運(yùn)行,如無提示錯(cuò)誤,則安裝成功
【然而,因?yàn)槲业南到y(tǒng)沒有安裝visual studio相關(guān)環(huán)境插件,報(bào)如下錯(cuò)誤】
ImportError: Could not find the DLL(s) 'msvcp140_1.dll'. TensorFlow requires that these DLLs be installed in a directory that is named in your %PATH% environment variable. You may install these DLLs by downloading "Microsoft C++ Redistributable for Visual Studio 2015, 2017 and 2019" ...
按錯(cuò)誤提示,去“https://support.microsoft.com/zh-cn/help/2977003/the-latest-supported-visual-c-downloads”處下載相應(yīng)的VS環(huán)境插件就好了。我是64位系統(tǒng),所以選擇x64版本:
下載安裝后,按提示重啟電腦,即可解決問題。
【如有碰到其余問題,歡迎在評(píng)論區(qū)留言】
?
?
【附錄一:使用清華鏡像下載tensorflow。有空再來研習(xí)所下載的每一個(gè)庫的作用】
Collecting tensorflow
? Downloading https://pypi.tuna.tsinghua.edu.cn/packages/e9/58/25a8d09901992596f057c22ef17832f2f57ea4d84b994f92ea88d0c49ca3/tensorflow-2.2.0-cp35-cp35m-win_amd64.whl (459.1MB)
? ? 100% |████████████████████████████████| 459.1MB 2.6kB/s
Collecting grpcio>=1.8.6 (from tensorflow)
? Downloading https://pypi.tuna.tsinghua.edu.cn/packages/9a/70/47389dc7521426e021159b4ca275761070c2788ede6dcc385f18957a8a47/grpcio-1.29.0-cp35-cp35m-win_amd64.whl (2.4MB)
? ? 100% |████████████████████████████████| 2.4MB 508kB/s
Collecting astunparse==1.6.3 (from tensorflow)
? Downloading https://pypi.tuna.tsinghua.edu.cn/packages/2b/03/13dde6512ad7b4557eb792fbcf0c653af6076b81e5941d36ec61f7ce6028/astunparse-1.6.3-py2.py3-none-any.whl
Collecting scipy==1.4.1; python_version >= "3" (from tensorflow)
? Downloading https://pypi.tuna.tsinghua.edu.cn/packages/ef/ae/78bbaf498bba92e5ce5903b096b75b5e1f9f82a742fc37a6595892f1ffca/scipy-1.4.1-cp35-cp35m-win_amd64.whl (30.8MB)
? ? 100% |████████████████████████████████| 30.8MB 43kB/s
Collecting numpy<2.0,>=1.16.0 (from tensorflow)
? Downloading https://pypi.tuna.tsinghua.edu.cn/packages/ed/09/ff8f529a5548ff788765f66a81ef751130f26f8c7d517e94d3dbf3ba1ed5/numpy-1.18.5-cp35-cp35m-win_amd64.whl (12.7MB)
? ? 100% |████████████████████████████████| 12.7MB 90kB/s
Collecting google-pasta>=0.1.8 (from tensorflow)
? Downloading https://pypi.tuna.tsinghua.edu.cn/packages/a3/de/c648ef6835192e6e2cc03f40b19eeda4382c49b5bafb43d88b931c4c74ac/google_pasta-0.2.0-py3-none-any.whl (57kB)
? ? 100% |████████████████████████████████| 61kB 4.7MB/s
Collecting six>=1.12.0 (from tensorflow)
? Downloading https://pypi.tuna.tsinghua.edu.cn/packages/ee/ff/48bde5c0f013094d729fe4b0316ba2a24774b3ff1c52d924a8a4cb04078a/six-1.15.0-py2.py3-none-any.whl
Collecting keras-preprocessing>=1.1.0 (from tensorflow)
? Downloading https://pypi.tuna.tsinghua.edu.cn/packages/79/4c/7c3275a01e12ef9368a892926ab932b33bb13d55794881e3573482b378a7/Keras_Preprocessing-1.1.2-py2.py3-none-any.whl (42kB)
? ? 100% |████████████████████████████████| 51kB 2.1MB/s
Collecting protobuf>=3.8.0 (from tensorflow)
? Downloading https://pypi.tuna.tsinghua.edu.cn/packages/f8/4c/f66908eeadfb7a2e41a462fae7f925aa7b54cf555ef331e4b45e59b6859d/protobuf-3.12.2-cp35-cp35m-win_amd64.whl (1.1MB)
? ? 100% |████████████████████████████████| 1.1MB 616kB/s
Collecting absl-py>=0.7.0 (from tensorflow)
? Downloading https://pypi.tuna.tsinghua.edu.cn/packages/1a/53/9243c600e047bd4c3df9e69cfabc1e8004a82cac2e0c484580a78a94ba2a/absl-py-0.9.0.tar.gz (104kB)
? ? 100% |████████████████████████████████| 112kB 2.1MB/s
Collecting tensorflow-estimator<2.3.0,>=2.2.0 (from tensorflow)
? Downloading https://pypi.tuna.tsinghua.edu.cn/packages/a4/f5/926ae53d6a226ec0fda5208e0e581cffed895ccc89e36ba76a8e60895b78/tensorflow_estimator-2.2.0-py2.py3-none-any.whl (454kB)
? ? 100% |████████████████████████████████| 460kB 520kB/s
Collecting opt-einsum>=2.3.2 (from tensorflow)
? Downloading https://pypi.tuna.tsinghua.edu.cn/packages/63/a5/e6c07b08b934831ccb8c98ee335e66b7761c5754ee3cabfe4c11d0b1af28/opt_einsum-3.2.1-py3-none-any.whl (63kB)
? ? 100% |████████████████████████████████| 71kB 2.0MB/s
Collecting gast==0.3.3 (from tensorflow)
? Downloading https://pypi.tuna.tsinghua.edu.cn/packages/d6/84/759f5dd23fec8ba71952d97bcc7e2c9d7d63bdc582421f3cd4be845f0c98/gast-0.3.3-py2.py3-none-any.whl
Collecting termcolor>=1.1.0 (from tensorflow)
? Downloading https://pypi.tuna.tsinghua.edu.cn/packages/8a/48/a76be51647d0eb9f10e2a4511bf3ffb8cc1e6b14e9e4fab46173aa79f981/termcolor-1.1.0.tar.gz
Collecting wrapt>=1.11.1 (from tensorflow)
? Downloading https://pypi.tuna.tsinghua.edu.cn/packages/82/f7/e43cefbe88c5fd371f4cf0cf5eb3feccd07515af9fd6cf7dbf1d1793a797/wrapt-1.12.1.tar.gz
Collecting tensorboard<2.3.0,>=2.2.0 (from tensorflow)
? Downloading https://pypi.tuna.tsinghua.edu.cn/packages/1d/74/0a6fcb206dcc72a6da9a62dd81784bfdbff5fedb099982861dc2219014fb/tensorboard-2.2.2-py3-none-any.whl (3.0MB)
? ? 100% |████████████████████████████████| 3.0MB 310kB/s
Requirement already satisfied (use --upgrade to upgrade): wheel>=0.26; python_version >= "3" in d:\program files\anaconda\lib\site-packages (from tensorflow)
Collecting h5py<2.11.0,>=2.10.0 (from tensorflow)
? Downloading https://pypi.tuna.tsinghua.edu.cn/packages/25/81/be3e43b143ee6b40cebb3d6e61da8ce74a03221791134f16dd016a497c23/h5py-2.10.0-cp35-cp35m-win_amd64.whl (2.4MB)
? ? 100% |████████████████████████████████| 2.4MB 409kB/s
Requirement already satisfied (use --upgrade to upgrade): setuptools in d:\program files\anaconda\lib\site-packages\setuptools-27.2.0-py3.5.egg (from protobuf>=3.8.0->tensorflow)
Collecting tensorboard-plugin-wit>=1.6.0 (from tensorboard<2.3.0,>=2.2.0->tensorflow)
? Downloading https://pypi.tuna.tsinghua.edu.cn/packages/51/cd/a0c1f9e4582ea64dddf76c1b808b318d01e3b858a51c715bffab1016ecc7/tensorboard_plugin_wit-1.6.0.post3-py3-none-any.whl (777kB)
? ? 100% |████████████████████████████████| 778kB 800kB/s
Collecting markdown>=2.6.8 (from tensorboard<2.3.0,>=2.2.0->tensorflow)
? Downloading https://pypi.tuna.tsinghua.edu.cn/packages/a4/63/eaec2bd025ab48c754b55e8819af0f6a69e2b1e187611dd40cbbe101ee7f/Markdown-3.2.2-py3-none-any.whl (88kB)
? ? 100% |████████████████████████████████| 92kB 1.4MB/s
Collecting werkzeug>=0.11.15 (from tensorboard<2.3.0,>=2.2.0->tensorflow)
? Downloading https://pypi.tuna.tsinghua.edu.cn/packages/cc/94/5f7079a0e00bd6863ef8f1da638721e9da21e5bacee597595b318f71d62e/Werkzeug-1.0.1-py2.py3-none-any.whl (298kB)
? ? 100% |████████████████████████████████| 307kB 1.3MB/s
Collecting google-auth-oauthlib<0.5,>=0.4.1 (from tensorboard<2.3.0,>=2.2.0->tensorflow)
? Downloading https://pypi.tuna.tsinghua.edu.cn/packages/7b/b8/88def36e74bee9fce511c9519571f4e485e890093ab7442284f4ffaef60b/google_auth_oauthlib-0.4.1-py2.py3-none-any.whl
Collecting requests<3,>=2.21.0 (from tensorboard<2.3.0,>=2.2.0->tensorflow)
? Downloading https://pypi.tuna.tsinghua.edu.cn/packages/1a/70/1935c770cb3be6e3a8b78ced23d7e0f3b187f5cbfab4749523ed65d7c9b1/requests-2.23.0-py2.py3-none-any.whl (58kB)
? ? 100% |████████████████████████████████| 61kB 1.5MB/s
Collecting google-auth<2,>=1.6.3 (from tensorboard<2.3.0,>=2.2.0->tensorflow)
? Downloading https://pypi.tuna.tsinghua.edu.cn/packages/9f/87/8f8d09ba959b2e51508cfcf3350e7df6ed0d1e06c7e056ca1a28e00e982a/google_auth-1.17.2-py2.py3-none-any.whl (90kB)
? ? 100% |████████████████████████████████| 92kB 1.9MB/s
Collecting importlib-metadata; python_version < "3.8" (from markdown>=2.6.8->tensorboard<2.3.0,>=2.2.0->tensorflow)
? Downloading https://pypi.tuna.tsinghua.edu.cn/packages/98/13/a1d703ec396ade42c1d33df0e1cb691a28b7c08b336a5683912c87e04cd7/importlib_metadata-1.6.1-py2.py3-none-any.whl
Collecting requests-oauthlib>=0.7.0 (from google-auth-oauthlib<0.5,>=0.4.1->tensorboard<2.3.0,>=2.2.0->tensorflow)
? Downloading https://pypi.tuna.tsinghua.edu.cn/packages/a3/12/b92740d845ab62ea4edf04d2f4164d82532b5a0b03836d4d4e71c6f3d379/requests_oauthlib-1.3.0-py2.py3-none-any.whl
Collecting chardet<4,>=3.0.2 (from requests<3,>=2.21.0->tensorboard<2.3.0,>=2.2.0->tensorflow)
? Downloading https://pypi.tuna.tsinghua.edu.cn/packages/bc/a9/01ffebfb562e4274b6487b4bb1ddec7ca55ec7510b22e4c51f14098443b8/chardet-3.0.4-py2.py3-none-any.whl (133kB)
? ? 100% |████████████████████████████████| 143kB 86kB/s
Collecting idna<3,>=2.5 (from requests<3,>=2.21.0->tensorboard<2.3.0,>=2.2.0->tensorflow)
? Downloading https://pypi.tuna.tsinghua.edu.cn/packages/89/e3/afebe61c546d18fb1709a61bee788254b40e736cff7271c7de5de2dc4128/idna-2.9-py2.py3-none-any.whl (58kB)
? ? 100% |████████████████████████████████| 61kB 183kB/s
Collecting urllib3!=1.25.0,!=1.25.1,<1.26,>=1.21.1 (from requests<3,>=2.21.0->tensorboard<2.3.0,>=2.2.0->tensorflow)
? Downloading https://pypi.tuna.tsinghua.edu.cn/packages/e1/e5/df302e8017440f111c11cc41a6b432838672f5a70aa29227bf58149dc72f/urllib3-1.25.9-py2.py3-none-any.whl (126kB)
? ? 100% |████████████████████████████████| 133kB 266kB/s
Collecting certifi>=2017.4.17 (from requests<3,>=2.21.0->tensorboard<2.3.0,>=2.2.0->tensorflow)
? Downloading https://pypi.tuna.tsinghua.edu.cn/packages/98/99/def511020aa8f663d4a2cfaa38467539e864799289ff354569e339e375b1/certifi-2020.4.5.2-py2.py3-none-any.whl (157kB)
? ? 100% |████████████████████████████████| 163kB 513kB/s
Collecting pyasn1-modules>=0.2.1 (from google-auth<2,>=1.6.3->tensorboard<2.3.0,>=2.2.0->tensorflow)
? Downloading https://pypi.tuna.tsinghua.edu.cn/packages/95/de/214830a981892a3e286c3794f41ae67a4495df1108c3da8a9f62159b9a9d/pyasn1_modules-0.2.8-py2.py3-none-any.whl (155kB)
? ? 100% |████████████████████████████████| 163kB 269kB/s
Collecting cachetools<5.0,>=2.0.0 (from google-auth<2,>=1.6.3->tensorboard<2.3.0,>=2.2.0->tensorflow)
? Downloading https://pypi.tuna.tsinghua.edu.cn/packages/b3/59/524ffb454d05001e2be74c14745b485681c6ed5f2e625f71d135704c0909/cachetools-4.1.0-py3-none-any.whl
Collecting rsa<5,>=3.1.4; python_version >= "3" (from google-auth<2,>=1.6.3->tensorboard<2.3.0,>=2.2.0->tensorflow)
? Downloading https://pypi.tuna.tsinghua.edu.cn/packages/9b/95/c62b736e9d474bc5c6847bf1449d6091ff413aee136af7356c3cdeee141a/rsa-4.6-py2.py3-none-any.whl
Collecting zipp>=0.5 (from importlib-metadata; python_version < "3.8"->markdown>=2.6.8->tensorboard<2.3.0,>=2.2.0->tensorflow)
? Downloading https://pypi.tuna.tsinghua.edu.cn/packages/b2/34/bfcb43cc0ba81f527bc4f40ef41ba2ff4080e047acb0586b56b3d017ace4/zipp-3.1.0-py3-none-any.whl
Collecting oauthlib>=3.0.0 (from requests-oauthlib>=0.7.0->google-auth-oauthlib<0.5,>=0.4.1->tensorboard<2.3.0,>=2.2.0->tensorflow)
? Downloading https://pypi.tuna.tsinghua.edu.cn/packages/05/57/ce2e7a8fa7c0afb54a0581b14a65b56e62b5759dbc98e80627142b8a3704/oauthlib-3.1.0-py2.py3-none-any.whl (147kB)
? ? 100% |████████████████████████████████| 153kB 1.1MB/s
Collecting pyasn1<0.5.0,>=0.4.6 (from pyasn1-modules>=0.2.1->google-auth<2,>=1.6.3->tensorboard<2.3.0,>=2.2.0->tensorflow)
? Downloading https://pypi.tuna.tsinghua.edu.cn/packages/62/1e/a94a8d635fa3ce4cfc7f506003548d0a2447ae76fd5ca53932970fe3053f/pyasn1-0.4.8-py2.py3-none-any.whl (77kB)
? ? 100% |████████████████████████████████| 81kB 1.3MB/s
Building wheels for collected packages: absl-py, termcolor, wrapt
? Running setup.py bdist_wheel for absl-py ... done
? Stored in directory: C:\Users\SEASON\AppData\Local\pip\Cache\wheels\55\fd\b5\4db4cce08516c3aaa68ee4c843439f45c7fcf177320ba63d9f
? Running setup.py bdist_wheel for termcolor ... done
? Stored in directory: C:\Users\SEASON\AppData\Local\pip\Cache\wheels\e3\d8\fc\50ab6e66e3dead21d5afff006dc5298913a3064be2b1105359
? Running setup.py bdist_wheel for wrapt ... done
? Stored in directory: C:\Users\SEASON\AppData\Local\pip\Cache\wheels\68\e3\d7\4b6eee6f5d547bdfd97ba406128db66c5654dfb831fda163a2
Successfully built absl-py termcolor wrapt
Installing collected packages: six, grpcio, astunparse, numpy, scipy, google-pasta, keras-preprocessing, protobuf, absl-py, tensorflow-estimator, opt-einsum, gast, termcolor, wrapt, tensorboard-plugin-wit, zipp, importlib-metadata, markdown, werkzeug, oauthlib, chardet, idna, urllib3, certifi, requests, requests-oauthlib, pyasn1, pyasn1-modules, cachetools, rsa, google-auth, google-auth-oauthlib, tensorboard, h5py, tensorflow
? Found existing installation: six 1.10.0
? ? 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.10.0:
? ? ? Successfully uninstalled six-1.10.0
? Found existing installation: numpy 1.11.1
? ? Uninstalling numpy-1.11.1:
? ? ? Successfully uninstalled numpy-1.11.1
? Found existing installation: scipy 0.18.1
? ? Uninstalling scipy-0.18.1:
? ? ? Successfully uninstalled scipy-0.18.1
? Found existing installation: wrapt 1.10.6
? ? DEPRECATION: Uninstalling a distutils installed project (wrapt) 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 wrapt-1.10.6:
? ? ? Successfully uninstalled wrapt-1.10.6
? Found existing installation: Werkzeug 0.11.11
? ? DEPRECATION: Uninstalling a distutils installed project (werkzeug) 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 Werkzeug-0.11.11:
? ? ? Successfully uninstalled Werkzeug-0.11.11
? Found existing installation: idna 2.1
? ? Uninstalling idna-2.1:
? ? ? Successfully uninstalled idna-2.1
? Found existing installation: requests 2.11.1
? ? Uninstalling requests-2.11.1:
? ? ? Successfully uninstalled requests-2.11.1
? Found existing installation: pyasn1 0.1.9
? ? DEPRECATION: Uninstalling a distutils installed project (pyasn1) 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 pyasn1-0.1.9:
? ? ? Successfully uninstalled pyasn1-0.1.9
? Found existing installation: h5py 2.6.0
? ? Uninstalling h5py-2.6.0:
? ? ? Successfully uninstalled h5py-2.6.0
Successfully installed absl-py-0.9.0 astunparse-1.6.3 cachetools-4.1.0 certifi-2020.4.5.2 chardet-3.0.4 gast-0.3.3 google-auth-1.17.2 google-auth-oauthlib-0.4.1 google-pasta-0.2.0 grpcio-1.29.0 h5py-2.10.0 idna-2.9 importlib-metadata-1.6.1 keras-preprocessing-1.1.2 markdown-3.2.2 numpy-1.18.5 oauthlib-3.1.0 opt-einsum-3.2.1 protobuf-3.12.2 pyasn1-0.4.8 pyasn1-modules-0.2.8 requests-2.23.0 requests-oauthlib-1.3.0 rsa-4.6 scipy-1.4.1 six-1.15.0 tensorboard-2.2.2 tensorboard-plugin-wit-1.6.0.post3 tensorflow-2.2.0 tensorflow-estimator-2.2.0 termcolor-1.1.0 urllib3-1.25.9 werkzeug-1.0.1 wrapt-1.12.1 zipp-3.1.0
?
?
?
?
?
?
?
?
總結(jié)
以上是生活随笔為你收集整理的Tensorflow入门笔记【一】环境的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: MATALB- robotic Tool
- 下一篇: 思维导图 基础篇(01)概述