python- tensorflow安裝
之前一直在win10系統下跑Python程式,過程中需要載入各種各樣的庫,今天把安裝方法整理一下
Env:Win10、Python3.6
Time:20181005
author:New(In XATU)
概要:
1、命令自動安裝
2、手動安裝
3、安裝工具
-------------------------------------------------
1、在CMD視窗自動安裝
將目錄切換搭配pip安裝位置或者將檔案複製到pip安裝的位置,也方便以後找,一般在C:\Software\Python\Scripts目錄下
1.1沒有安裝pip,一路cd到easy_install.exe所在的地方,執行指令“easy_install.exe pip”,就安裝好pip了;
Microsoft Windows [版本 10.0.17134.285] (c) 2018 Microsoft Corporation。保留所有權利。
C:\Users\Administrator>cd C:\Software\Python\Scripts
C:\Software\Python\Scripts>pip install --upgrade tensorflow Collecting tensorflow Downloading https://files.pythonhosted.org/packages/c1/e1/a5693a158f3867417d7b50bd0514c83304706242fae74463705b8c373777/tensorflow-1.11.0-cp36-cp36m-win_amd64.whl (46.9MB) 2% |█ | 1.2MB 10kB/s eta 1:09:23Exception: Traceback (most recent call last): File "c:\software\python\lib\site-packages\pip\_vendor\urllib3\response.py", line 331, in _error_catcher yield File "c:\software\python\lib\site-packages\pip\_vendor\urllib3\response.py", line 413, in read data = self._fp.read(amt) File "c:\software\python\lib\site-packages\pip\_vendor\cachecontrol\filewrapper.py", line 62, in read data = self.__fp.read(amt) File "c:\software\python\lib\http\client.py", line 449, in read n = self.readinto(b) File "c:\software\python\lib\http\client.py", line 493, in readinto n = self.fp.readinto(b) File "c:\software\python\lib\socket.py", line 586, in readinto return self._sock.recv_into(b) File "c:\software\python\lib\ssl.py", line 1002, in recv_into return self.read(nbytes, buffer) File "c:\software\python\lib\ssl.py", line 865, in read return self._sslobj.read(len, buffer) File "c:\software\python\lib\ssl.py", line 625, in read v = self._sslobj.read(len, buffer) socket.timeout: The read operation timed out
During handling of the above exception, another exception occurred:
Traceback (most recent call last): File "c:\software\python\lib\site-packages\pip\_internal\basecommand.py", line 141, in main status = self.run(options, args) File "c:\software\python\lib\site-packages\pip\_internal\commands\install.py", line 299, in run resolver.resolve(requirement_set) File "c:\software\python\lib\site-packages\pip\_internal\resolve.py", line 102, in resolve self._resolve_one(requirement_set, req) File "c:\software\python\lib\site-packages\pip\_internal\resolve.py", line 256, in _resolve_one abstract_dist = self._get_abstract_dist_for(req_to_install) File "c:\software\python\lib\site-packages\pip\_internal\resolve.py", line 209, in _get_abstract_dist_for self.require_hashes File "c:\software\python\lib\site-packages\pip\_internal\operations\prepare.py", line 283, in prepare_linked_requirement progress_bar=self.progress_bar File "c:\software\python\lib\site-packages\pip\_internal\download.py", line 836, in unpack_url progress_bar=progress_bar File "c:\software\python\lib\site-packages\pip\_internal\download.py", line 673, in unpack_http_url progress_bar) File "c:\software\python\lib\site-packages\pip\_internal\download.py", line 897, in _download_http_url _download_url(resp, link, content_file, hashes, progress_bar) File "c:\software\python\lib\site-packages\pip\_internal\download.py", line 617, in _download_url hashes.check_against_chunks(downloaded_chunks) File "c:\software\python\lib\site-packages\pip\_internal\utils\hashes.py", line 48, in check_against_chunks for chunk in chunks: File "c:\software\python\lib\site-packages\pip\_internal\download.py", line 585, in written_chunks for chunk in chunks: File "c:\software\python\lib\site-packages\pip\_internal\utils\ui.py", line 159, in iter for x in it: File "c:\software\python\lib\site-packages\pip\_internal\download.py", line 574, in resp_read decode_content=False): File "c:\software\python\lib\site-packages\pip\_vendor\urllib3\response.py", line 465, in stream data = self.read(amt=amt, decode_content=decode_content) File "c:\software\python\lib\site-packages\pip\_vendor\urllib3\response.py", line 430, in read raise IncompleteRead(self._fp_bytes_read, self.length_remaining) File "c:\software\python\lib\contextlib.py", line 99, in __exit__ self.gen.throw(type, value, traceback) File "c:\software\python\lib\site-packages\pip\_vendor\urllib3\response.py", line 336, in _error_catcher raise ReadTimeoutError(self._pool, None, 'Read timed out.') pip._vendor.urllib3.exceptions.ReadTimeoutError: HTTPSConnectionPool(host='files.pythonhosted.org', port=443): Read timed out.
2、手動安裝
報錯了,copy tensorflow下載連結,瀏覽器下載完畢,手動安裝
https://files.pythonhosted.org/packages/c1/e1/a5693a158f3867417d7b50bd0514c83304706242fae74463705b8c373777/tensorflow-1.11.0-cp36-cp36m-win_amd64.whl
將下文的tensorflow-1.11.0-cp36-cp36m-win_amd64.whl 複製到 上述目錄C:\Software\Python下,手動安裝
輸入安裝指令,格式為pip +install+somewhat.whl,eg:
pip install tensorflow-1.11.0-cp36-cp36m-win_amd64.whl
安裝過程詳細如下
-------------------------------------------------------
C:\Software\Python\Scripts>easy_install tensorflowSearching for tensorflow Reading https://pypi.python.org/simple/tensorflow/ No local packages or working download links found for tensorflow error: Could not find suitable distribution for Requirement.parse('tensorflow')
C:\Software\Python\Scripts>cd..
C:\Software\Python> pip install tensorflow-1.11.0-cp36-cp36m-win_amd64.whlProcessing c:\software\python\tensorflow-1.11.0-cp36-cp36m-win_amd64.whl Collecting grpcio>=1.8.6 (from tensorflow==1.11.0) Downloading https://files.pythonhosted.org/packages/0e/13/43a98e233716f1d9846ca65322b065443af5ea1aed5f631e240d231174c0/grpcio-1.15.0-cp36-cp36m-win_amd64.whl (1.5MB) 100% |████████████████████████████████| 1.5MB 25kB/s Requirement already satisfied: numpy>=1.13.3 in c:\software\python\lib\site-packages (from tensorflow==1.11.0) (1.14.2) Collecting gast>=0.2.0 (from tensorflow==1.11.0) Downloading https://files.pythonhosted.org/packages/5c/78/ff794fcae2ce8aa6323e789d1f8b3b7765f601e7702726f430e814822b96/gast-0.2.0.tar.gz Collecting wheel>=0.26 (from tensorflow==1.11.0) Downloading https://files.pythonhosted.org/packages/fc/e9/05316a1eec70c2bfc1c823a259546475bd7636ba6d27ec80575da523bc34/wheel-0.32.1-py2.py3-none-any.whl Collecting astor>=0.6.0 (from tensorflow==1.11.0) Downloading https://files.pythonhosted.org/packages/35/6b/11530768cac581a12952a2aad00e1526b89d242d0b9f59534ef6e6a1752f/astor-0.7.1-py2.py3-none-any.whl Requirement already satisfied: six>=1.10.0 in c:\software\python\lib\site-packages (from tensorflow==1.11.0) (1.11.0) Collecting termcolor>=1.1.0 (from tensorflow==1.11.0) Downloading https://files.pythonhosted.org/packages/8a/48/a76be51647d0eb9f10e2a4511bf3ffb8cc1e6b14e9e4fab46173aa79f981/termcolor-1.1.0.tar.gz Collecting protobuf>=3.6.0 (from tensorflow==1.11.0) Downloading https://files.pythonhosted.org/packages/e8/df/d606d07cff0fc8d22abcc54006c0247002d11a7f2d218eb008d48e76851d/protobuf-3.6.1-cp36-cp36m-win_amd64.whl (1.1MB) 100% |████████████████████████████████| 1.1MB 12kB/s Requirement already satisfied: setuptools<=39.1.0 in c:\software\python\lib\site-packages (from tensorflow==1.11.0) (28.8.0) Collecting keras-preprocessing>=1.0.3 (from tensorflow==1.11.0) Downloading https://files.pythonhosted.org/packages/fc/94/74e0fa783d3fc07e41715973435dd051ca89c550881b3454233c39c73e69/Keras_Preprocessing-1.0.5-py2.py3-none-any.whl Collecting keras-applications>=1.0.5 (from tensorflow==1.11.0) Downloading https://files.pythonhosted.org/packages/3f/c4/2ff40221029f7098d58f8d7fb99b97e8100f3293f9856f0fb5834bef100b/Keras_Applications-1.0.6-py2.py3-none-any.whl (44kB) 100% |████████████████████████████████| 51kB 52kB/s Collecting absl-py>=0.1.6 (from tensorflow==1.11.0) Downloading https://files.pythonhosted.org/packages/16/db/cce5331638138c178dd1d5fb69f3f55eb3787a12efd9177177ae203e847f/absl-py-0.5.0.tar.gz (90kB) 100% |████████████████████████████████| 92kB 15kB/s Collecting tensorboard<1.12.0,>=1.11.0 (from tensorflow==1.11.0) Downloading https://files.pythonhosted.org/packages/9b/2f/4d788919b1feef04624d63ed6ea45a49d1d1c834199ec50716edb5d310f4/tensorboard-1.11.0-py3-none-any.whl (3.0MB) 100% |████████████████████████████████| 3.0MB 45kB/s Collecting h5py (from keras-applications>=1.0.5->tensorflow==1.11.0) Downloading https://files.pythonhosted.org/packages/12/6c/00c38c5ce9322f1cc421d93217c44739646a106c61859622eccc297a5c05/h5py-2.8.0-cp36-cp36m-win_amd64.whl (2.3MB) 100% |████████████████████████████████| 2.3MB 39kB/s Collecting markdown>=2.6.8 (from tensorboard<1.12.0,>=1.11.0->tensorflow==1.11.0) Downloading https://files.pythonhosted.org/packages/7a/6b/5600647404ba15545ec37d2f7f58844d690baf2f81f3a60b862e48f29287/Markdown-3.0.1-py2.py3-none-any.whl (89kB) 100% |████████████████████████████████| 92kB 41kB/s Collecting werkzeug>=0.11.10 (from tensorboard<1.12.0,>=1.11.0->tensorflow==1.11.0) Downloading https://files.pythonhosted.org/packages/20/c4/12e3e56473e52375aa29c4764e70d1b8f3efa6682bef8d0aae04fe335243/Werkzeug-0.14.1-py2.py3-none-any.whl (322kB) 100% |████████████████████████████████| 327kB 35kB/s Installing collected packages: grpcio, gast, wheel, astor, termcolor, protobuf, keras-preprocessing, h5py, keras-applications, absl-py, markdown, werkzeug, tensorboard, tensorflow Running setup.py install for gast ... done Running setup.py install for termcolor ... done Running setup.py install for absl-py ... doneSuccessfully installed absl-py-0.5.0 astor-0.7.1 gast-0.2.0 grpcio-1.15.0 h5py-2.8.0 keras-applications-1.0.6 keras-preprocessing-1.0.5 markdown-3.0.1 protobuf-3.6.1 tensorboard-1.11.0 tensorflow-1.11.0 termcolor-1.1.0 werkzeug-0.14.1 wheel-0.32.1
————------------------------------------------------
3、安裝工具
pip install +名稱 (ps:有時候pip版本較低,安裝出錯)
esay_install +名稱
或者先用esay_install 安裝最新的pip,在安裝
------------------------------------
今天就到這了,下次將更新tensorflow框架的配置及使用。