1. 程式人生 > >繼Pytorch後,win10下安裝tensorflow,沒用Anaconda,pip終端安裝

繼Pytorch後,win10下安裝tensorflow,沒用Anaconda,pip終端安裝

安裝好Pytorch後,在官網逗留一小段時間後,感覺有些乏懵,於是乘勝追擊,將tensorflow安裝上。

首先:

我在安裝Pytorch之前試了一次,失敗了

C:\Users\Shu\Desktop>pip install --upgrade --ignore-installed tensorflow
Collecting tensorflow
  Downloading https://files.pythonhosted.org/packages/05/cd/c171d2e33c0192b04560ce864c26eba83fed888fe5cd9ded661b2702f2ae/tensorflow-1.12.0-cp36-cp36m-win_amd64.whl (45.9MB)
    11% |████                            | 5.4MB 95kB/s eta 0:07:04Exception:
Traceback (most recent call last):
  File "c:\users\shu\appdata\local\programs\python\python36\lib\site-packages\pip\_vendor\urllib3\response.py", line 331, in _error_catcher
    yield
  File "c:\users\shu\appdata\local\programs\python\python36\lib\site-packages\pip\_vendor\urllib3\response.py", line 413, in read
    data = self._fp.read(amt)
  File "c:\users\shu\appdata\local\programs\python\python36\lib\site-packages\pip\_vendor\cachecontrol\filewrapper.py", line 62, in read
    data = self.__fp.read(amt)
  File "c:\users\shu\appdata\local\programs\python\python36\lib\http\client.py", line 449, in read
    n = self.readinto(b)
  File "c:\users\shu\appdata\local\programs\python\python36\lib\http\client.py", line 493, in readinto
    n = self.fp.readinto(b)
  File "c:\users\shu\appdata\local\programs\python\python36\lib\socket.py", line 586, in readinto
    return self._sock.recv_into(b)
  File "c:\users\shu\appdata\local\programs\python\python36\lib\ssl.py", line 1009, in recv_into
    return self.read(nbytes, buffer)
  File "c:\users\shu\appdata\local\programs\python\python36\lib\ssl.py", line 871, in read
    return self._sslobj.read(len, buffer)
  File "c:\users\shu\appdata\local\programs\python\python36\lib\ssl.py", line 631, 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:\users\shu\appdata\local\programs\python\python36\lib\site-packages\pip\_internal\cli\base_command.py", line 143, in main
    status = self.run(options, args)
  File "c:\users\shu\appdata\local\programs\python\python36\lib\site-packages\pip\_internal\commands\install.py", line 318, in run
    resolver.resolve(requirement_set)
  File "c:\users\shu\appdata\local\programs\python\python36\lib\site-packages\pip\_internal\resolve.py", line 102, in resolve
    self._resolve_one(requirement_set, req)
  File "c:\users\shu\appdata\local\programs\python\python36\lib\site-packages\pip\_internal\resolve.py", line 256, in _resolve_one
    abstract_dist = self._get_abstract_dist_for(req_to_install)
  File "c:\users\shu\appdata\local\programs\python\python36\lib\site-packages\pip\_internal\resolve.py", line 209, in _get_abstract_dist_for
    self.require_hashes
  File "c:\users\shu\appdata\local\programs\python\python36\lib\site-packages\pip\_internal\operations\prepare.py", line 283, in prepare_linked_requirement
    progress_bar=self.progress_bar
  File "c:\users\shu\appdata\local\programs\python\python36\lib\site-packages\pip\_internal\download.py", line 836, in unpack_url
    progress_bar=progress_bar
  File "c:\users\shu\appdata\local\programs\python\python36\lib\site-packages\pip\_internal\download.py", line 673, in unpack_http_url
    progress_bar)
  File "c:\users\shu\appdata\local\programs\python\python36\lib\site-packages\pip\_internal\download.py", line 897, in _download_http_url
    _download_url(resp, link, content_file, hashes, progress_bar)
  File "c:\users\shu\appdata\local\programs\python\python36\lib\site-packages\pip\_internal\download.py", line 617, in _download_url
    hashes.check_against_chunks(downloaded_chunks)
  File "c:\users\shu\appdata\local\programs\python\python36\lib\site-packages\pip\_internal\utils\hashes.py", line 48, in check_against_chunks
    for chunk in chunks:
  File "c:\users\shu\appdata\local\programs\python\python36\lib\site-packages\pip\_internal\download.py", line 585, in written_chunks
    for chunk in chunks:
  File "c:\users\shu\appdata\local\programs\python\python36\lib\site-packages\pip\_internal\utils\ui.py", line 159, in iter
    for x in it:
  File "c:\users\shu\appdata\local\programs\python\python36\lib\site-packages\pip\_internal\download.py", line 574, in resp_read
    decode_content=False):
  File "c:\users\shu\appdata\local\programs\python\python36\lib\site-packages\pip\_vendor\urllib3\response.py", line 465, in stream
    data = self.read(amt=amt, decode_content=decode_content)
  File "c:\users\shu\appdata\local\programs\python\python36\lib\site-packages\pip\_vendor\urllib3\response.py", line 430, in read
    raise IncompleteRead(self._fp_bytes_read, self.length_remaining)
  File "c:\users\shu\appdata\local\programs\python\python36\lib\contextlib.py", line 99, in __exit__
    self.gen.throw(type, value, traceback)
  File "c:\users\shu\appdata\local\programs\python\python36\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.

C:\Users\Shu\Desktop>pip install torch
Collecting torch
  Downloading https://files.pythonhosted.org/packages/5f/e9/bac4204fe9cb1a002ec6140b47f51affda1655379fe302a1caef421f9846/torch-0.1.2.post1.tar.gz
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "C:\Users\Shu\AppData\Local\Temp\pip-install-4qb8nh0y\torch\setup.py", line 11, in <module>
        raise RuntimeError(README)
    RuntimeError: PyTorch does not currently provide packages for PyPI (see status at https://github.com/pytorch/pytorch/issues/566).

    Please follow the instructions at http://pytorch.org/ to install with miniconda instead.


    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in C:\Users\Shu\AppData\Local\Temp\pip-install-4qb8nh0y\torch\

C:\Users\Shu\Desktop>pip install no-deps torchvision
Collecting no-deps
  Could not find a version that satisfies the requirement no-deps (from versions: )
No matching distribution found for no-deps

然後我按照上一篇部落格成功安裝上Pytorch。

現在我們來看看發生了什麼???


C:\Users\Shu\Desktop>pip install tensorflow
Requirement already satisfied: tensorflow in c:\users\shu\appdata\local\programs\python\python36\lib\site-packages (1.11.0)
Requirement already satisfied: grpcio>=1.8.6 in c:\users\shu\appdata\local\programs\python\python36\lib\site-packages (from tensorflow) (1.16.0)
Requirement already satisfied: numpy>=1.13.3 in c:\users\shu\appdata\local\programs\python\python36\lib\site-packages (from tensorflow) (1.15.3)
Requirement already satisfied: absl-py>=0.1.6 in c:\users\shu\appdata\local\programs\python\python36\lib\site-packages (from tensorflow) (0.6.1)
Requirement already satisfied: wheel>=0.26 in c:\users\shu\appdata\local\programs\python\python36\lib\site-packages (from tensorflow) (0.32.2)
Requirement already satisfied: tensorboard<1.12.0,>=1.11.0 in c:\users\shu\appdata\local\programs\python\python36\lib\site-packages (from tensorflow) (1.11.0)
Requirement already satisfied: setuptools<=39.1.0 in c:\users\shu\appdata\local\programs\python\python36\lib\site-packages (from tensorflow) (39.1.0)
Requirement already satisfied: gast>=0.2.0 in c:\users\shu\appdata\local\programs\python\python36\lib\site-packages (from tensorflow) (0.2.0)
Requirement already satisfied: keras-applications>=1.0.5 in c:\users\shu\appdata\local\programs\python\python36\lib\site-packages (from tensorflow) (1.0.6)
Requirement already satisfied: protobuf>=3.6.0 in c:\users\shu\appdata\local\programs\python\python36\lib\site-packages (from tensorflow) (3.6.1)
Requirement already satisfied: keras-preprocessing>=1.0.3 in c:\users\shu\appdata\local\programs\python\python36\lib\site-packages (from tensorflow) (1.0.5)
Requirement already satisfied: astor>=0.6.0 in c:\users\shu\appdata\local\programs\python\python36\lib\site-packages (from tensorflow) (0.7.1)
Requirement already satisfied: termcolor>=1.1.0 in c:\users\shu\appdata\local\programs\python\python36\lib\site-packages (from tensorflow) (1.1.0)
Requirement already satisfied: six>=1.10.0 in c:\users\shu\appdata\local\programs\python\python36\lib\site-packages (from tensorflow) (1.11.0)
Requirement already satisfied: markdown>=2.6.8 in c:\users\shu\appdata\local\programs\python\python36\lib\site-packages (from tensorboard<1.12.0,>=1.11.0->tensorflow) (3.0.1)
Requirement already satisfied: werkzeug>=0.11.10 in c:\users\shu\appdata\local\programs\python\python36\lib\site-packages (from tensorboard<1.12.0,>=1.11.0->tensorflow) (0.14.1)
Requirement already satisfied: h5py in c:\users\shu\appdata\local\programs\python\python36\lib\site-packages (from keras-applications>=1.0.5->tensorflow) (2.8.0)

C:\Users\Shu\Desktop>python
Python 3.6.4 (v3.6.4:d48eceb, Dec 19 2017, 06:54:40) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow
>>>

朋友們,有誰能告訴我,誰在我用電腦的這兩個小時偷偷給我裝好了tensorflow 麼?其實在安裝之前去檢視過中文版官網(http://www.tensorfly.cn/),顯示只支援python2.7版本,並且沒有win下的安裝。
在這裡插入圖片描述
我翻回去檢視Pytorch和torchvision安裝過程中,也就自己安裝了numpy和pillow這兩個庫,所以一臉懵逼,大家可以試一試。
上一篇部落格附上:(https://blog.csdn.net/weixin_43012220/article/details/83786637)

雖然我知道這樣搞可能這個環境不夠robust,但是誰就我們是新手,是自學呢,當你踩過所有的坑,相信這些坑能使你更加robust。