Pytorch 、torchvision、Tensorflow安装

admin 2018-09-16 阅读


版权声明:王家林大咖2018年新书《SPARK大数据商业实战三部曲》清华大学出版,清华大学出版社官方旗舰店(天猫)https://qhdx.tmall.com/?spm=a220o.1000855.1997427721.d4918089.4b2a2e5dT6bUsM https://blog.csdn.net/duan_zhihua/article/details/82720375

Pytorch、torchvision重新安装:

访问Pytorch的官网https://pytorch.org/,选择需要的版本,在页面的Run this command的栏目中会出现相应的安装命令。

pip3 install http://download.pytorch.org/whl/cpu/torch-0.4.1-cp36-cp36m-win_amd64.whl 
pip3 install torchvision

G:\ProgramData\Anaconda3\Scripts>pip3 install http://download.pytorch.org/whl/cpu/torch-0.4.1-cp36-cp36m-win_amd64.whl
Collecting torch==0.4.1 from http://download.pytorch.org/whl/cpu/torch-0.4.1-cp36-cp36m-win_amd64.whl
  Downloading http://download.pytorch.org/whl/cpu/torch-0.4.1-cp36-cp36m-win_amd64.whl (55.9MB)
    100% |████████████████████████████████| 55.9MB 12.8MB/s
torchvision 0.2.1 requires pillow>=4.1.1, which is not installed.
Installing collected packages: torch
Successfully installed torch-0.4.1

G:\ProgramData\Anaconda3\Scripts>
G:\ProgramData\Anaconda3\Scripts>pip3 install torchvision
Requirement already satisfied: torchvision in g:\programs\python\python36\lib\site-packages (0.2.1)
Requirement already satisfied: torch in g:\programs\python\python36\lib\site-packages (from torchvision) (0.4.1)
Requirement already satisfied: numpy in g:\programs\python\python36\lib\site-packages (from torchvision) (1.14.2+mkl)
Collecting pillow>=4.1.1 (from torchvision)
  Using cached https://files.pythonhosted.org/packages/1b/50/869910cd7110157fbefd0fed3db3656c1951f1bceecdd00e3716aa269609/Pillow-5.2.0-cp36-cp36m-win_amd64.whl
Requirement already satisfied: six in g:\programs\python\python36\lib\site-packages (from torchvision) (1.11.0)
Installing collected packages: pillow
Successfully installed pillow-5.2.0

G:\ProgramData\Anaconda3\Scripts>

 导入torchvision报错,提示找不到torchvision

(G:\ProgramData\Anaconda3) C:\Users\lenovo>python
Python 3.6.5 |Anaconda, Inc.| (default, Mar 29 2018, 13:32:41) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import torchvision
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'torchvision'

重新安装torchvision 

(G:\ProgramData\Anaconda3) C:\Users\lenovo>pip install  torchvision
Collecting torchvision
  Using cached https://files.pythonhosted.org/packages/ca/0d/f00b2885711e08bd71242ebe7b96561e6f6d01fdb4b9dcf4d37e2e13c5e1/torchvision-0.2.1-py2.py3-none-any.whl
Requirement already satisfied: numpy in g:\programdata\anaconda3\lib\site-packages (from torchvision) (1.14.3)
Requirement already satisfied: torch in g:\programdata\anaconda3\lib\site-packages (from torchvision) (0.4.1)
Requirement already satisfied: pillow>=4.1.1 in g:\programdata\anaconda3\lib\site-packages (from torchvision) (5.1.0)
Requirement already satisfied: six in g:\programdata\anaconda3\lib\site-packages (from torchvision) (1.11.0)
distributed 1.21.8 requires msgpack, which is not installed.
Installing collected packages: torchvision
Successfully installed torchvision-0.2.1
You are using pip version 10.0.1, however version 18.0 is available.
You should consider upgrading via the 'python -m pip install --upgrade pip' command.

检查pytorch,torchvision安装成功。

C:\Users\lenovo>python
Python 3.6.5 |Anaconda, Inc.| (default, Mar 29 2018, 13:32:41) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import torch
>>> import torchvision
>>>

在pytorch官网中Run this command可能需要代理访问Pytorch才显示命令,如不能访问,可以参考以下语句:

'conda,linux,cuda8,python2.7': 'conda install pytorch torchvision cuda80 -c pytorch',
        
        'conda,linux,cuda9.0,python2.7': 'conda install pytorch torchvision -c pytorch',
        
        'conda,linux,cuda9.2,python2.7': 'conda install pytorch torchvision cuda92 -c pytorch',
        
        'conda,linux,cudanone,python2.7': 'conda install pytorch-cpu torchvision-cpu -c pytorch',
        
        'conda,linux,cuda8,python3.5': 'conda install pytorch torchvision cuda80 -c pytorch',
        
        'conda,linux,cuda9.0,python3.5': 'conda install pytorch torchvision -c pytorch',
        
        'conda,linux,cuda9.2,python3.5': 'conda install pytorch torchvision cuda92 -c pytorch',
        
        'conda,linux,cudanone,python3.5': 'conda install pytorch-cpu torchvision-cpu -c pytorch',
        
        'conda,linux,cuda8,python3.6': 'conda install pytorch torchvision cuda80 -c pytorch',
        
        'conda,linux,cuda9.0,python3.6': 'conda install pytorch torchvision -c pytorch',
        
        'conda,linux,cuda9.2,python3.6': 'conda install pytorch torchvision cuda92 -c pytorch',
        
        'conda,linux,cudanone,python3.6': 'conda install pytorch-cpu torchvision-cpu -c pytorch',
        
        'conda,linux,cuda8,python3.7': 'conda install pytorch torchvision cuda80 -c pytorch',
        
        'conda,linux,cuda9.0,python3.7': 'conda install pytorch torchvision -c pytorch',
        
        'conda,linux,cuda9.2,python3.7': 'conda install pytorch torchvision cuda92 -c pytorch',
        
        'conda,linux,cudanone,python3.7': 'conda install pytorch-cpu torchvision-cpu -c pytorch',
        
        'conda,macos,cuda8,python2.7': 'conda install pytorch torchvision -c pytorch <br /> # MacOS Binaries dont support CUDA, install from source if CUDA is needed',
        
        'conda,macos,cuda9.0,python2.7': 'conda install pytorch torchvision -c pytorch <br /> # MacOS Binaries dont support CUDA, install from source if CUDA is needed',
        
        'conda,macos,cuda9.2,python2.7': 'conda install pytorch torchvision -c pytorch <br /> # MacOS Binaries dont support CUDA, install from source if CUDA is needed',
        
        'conda,macos,cudanone,python2.7': 'conda install pytorch torchvision -c pytorch',
        
        'conda,macos,cuda8,python3.5': 'conda install pytorch torchvision -c pytorch <br /> # MacOS Binaries dont support CUDA, install from source if CUDA is needed',
        
        'conda,macos,cuda9.0,python3.5': 'conda install pytorch torchvision -c pytorch <br /> # MacOS Binaries dont support CUDA, install from source if CUDA is needed',
        
        'conda,macos,cuda9.2,python3.5': 'conda install pytorch torchvision -c pytorch <br /> # MacOS Binaries dont support CUDA, install from source if CUDA is needed',
        
        'conda,macos,cudanone,python3.5': 'conda install pytorch torchvision -c pytorch',
        
        'conda,macos,cuda8,python3.6': 'conda install pytorch torchvision -c pytorch <br /> # MacOS Binaries dont support CUDA, install from source if CUDA is needed',
        
        'conda,macos,cuda9.0,python3.6': 'conda install pytorch torchvision -c pytorch <br /> # MacOS Binaries dont support CUDA, install from source if CUDA is needed',
        
        'conda,macos,cuda9.2,python3.6': 'conda install pytorch torchvision -c pytorch <br /> # MacOS Binaries dont support CUDA, install from source if CUDA is needed',
        
        'conda,macos,cudanone,python3.6': 'conda install pytorch torchvision -c pytorch',
        
        'conda,macos,cuda8,python3.7': 'conda install pytorch torchvision -c pytorch <br /> # MacOS Binaries dont support CUDA, install from source if CUDA is needed',
        
        'conda,macos,cuda9.0,python3.7': 'conda install pytorch torchvision -c pytorch <br /> # MacOS Binaries dont support CUDA, install from source if CUDA is needed',
        
        'conda,macos,cuda9.2,python3.7': 'conda install pytorch torchvision -c pytorch <br /> # MacOS Binaries dont support CUDA, install from source if CUDA is needed',
        
        'conda,macos,cudanone,python3.7': 'conda install pytorch torchvision -c pytorch',
        
        'conda,windows,cuda8,python2.7': '# PyTorch does not support Python 2.7 on Windows. Please install with Python 3.',
        
        'conda,windows,cuda9.0,python2.7': '# PyTorch does not support Python 2.7 on Windows. Please install with Python 3.',
        
        'conda,windows,cuda9.2,python2.7': '# PyTorch does not support Python 2.7 on Windows. Please install with Python 3.',
        
        'conda,windows,cudanone,python2.7': '# PyTorch does not support Python 2.7 on Windows. Please install with Python 3.',
        
        'conda,windows,cuda8,python3.5': 'conda install pytorch cuda80 -c pytorch <br /> pip3 install torchvision',
        
        'conda,windows,cuda9.0,python3.5': 'conda install pytorch -c pytorch <br /> pip3 install torchvision',
        
        'conda,windows,cuda9.2,python3.5': 'conda install pytorch cuda92 -c pytorch <br /> pip3 install torchvision',
        
        'conda,windows,cudanone,python3.5': 'conda install pytorch-cpu -c pytorch <br /> pip3 install torchvision',
        
        'conda,windows,cuda8,python3.6': 'conda install pytorch cuda80 -c pytorch <br /> pip3 install torchvision',
        
        'conda,windows,cuda9.0,python3.6': 'conda install pytorch -c pytorch <br /> pip3 install torchvision',
        
        'conda,windows,cuda9.2,python3.6': 'conda install pytorch cuda92 -c pytorch <br /> pip3 install torchvision',
        
        'conda,windows,cudanone,python3.6': 'conda install pytorch-cpu -c pytorch <br /> pip3 install torchvision',
        
        'conda,windows,cuda8,python3.7': 'conda install pytorch cuda80 -c pytorch <br /> pip3 install torchvision',
        
        'conda,windows,cuda9.0,python3.7': 'conda install pytorch -c pytorch <br /> pip3 install torchvision',
        
        'conda,windows,cuda9.2,python3.7': 'conda install pytorch cuda92 -c pytorch <br /> pip3 install torchvision',
        
        'conda,windows,cudanone,python3.7': 'conda install pytorch-cpu -c pytorch <br /> pip3 install torchvision',
        
        'pip,macos,cuda8,python2.7': 'pip install torch torchvision <br /> # MacOS Binaries dont support CUDA, install from source if CUDA is needed',
        
        'pip,macos,cuda9.0,python2.7': 'pip install torch torchvision <br /> # MacOS Binaries dont support CUDA, install from source if CUDA is needed',
        
        'pip,macos,cuda9.2,python2.7': 'pip install torch torchvision <br /> # MacOS Binaries dont support CUDA, install from source if CUDA is needed',
        
        'pip,macos,cudanone,python2.7': 'pip install torch torchvision',
        
        'pip,macos,cuda8,python3.5': 'pip3 install torch torchvision <br /> # MacOS Binaries dont support CUDA, install from source if CUDA is needed',
        
        'pip,macos,cuda9.0,python3.5': 'pip3 install torch torchvision <br /> # MacOS Binaries dont support CUDA, install from source if CUDA is needed',
        
        'pip,macos,cuda9.2,python3.5': 'pip3 install torch torchvision <br /> # MacOS Binaries dont support CUDA, install from source if CUDA is needed',
        
        'pip,macos,cudanone,python3.5': 'pip3 install torch torchvision',
        
        'pip,macos,cuda8,python3.6': 'pip3 install torch torchvision <br /> # MacOS Binaries dont support CUDA, install from source if CUDA is needed',
        
        'pip,macos,cuda9.0,python3.6': 'pip3 install torch torchvision <br /> # MacOS Binaries dont support CUDA, install from source if CUDA is needed',
        
        'pip,macos,cuda9.2,python3.6': 'pip3 install torch torchvision <br /> # MacOS Binaries dont support CUDA, install from source if CUDA is needed',
        
        'pip,macos,cudanone,python3.6': 'pip3 install torch torchvision',
        
        'pip,macos,cuda8,python3.7': 'pip3 install torch torchvision <br /> # MacOS Binaries dont support CUDA, install from source if CUDA is needed',
        
        'pip,macos,cuda9.0,python3.7': 'pip3 install torch torchvision <br /> # MacOS Binaries dont support CUDA, install from source if CUDA is needed',
        
        'pip,macos,cuda9.2,python3.7': 'pip3 install torch torchvision <br /> # MacOS Binaries dont support CUDA, install from source if CUDA is needed',
        
        'pip,macos,cudanone,python3.7': 'pip3 install torch torchvision',
        
        'pip,linux,cudanone,python2.7': 'pip install http://download.pytorch.org/whl/cpu/torch-0.4.1-cp27-cp27mu-linux_x86_64.whl <br/> pip install torchvision <br/><br/> # if the above command does not work, then you have python 2.7 UCS2, use this command <br/> pip install http://download.pytorch.org/whl/cpu/torch-0.4.1-cp27-cp27m-linux_x86_64.whl',
        
        'pip,linux,cuda8,python2.7': 'pip install http://download.pytorch.org/whl/cu80/torch-0.4.1-cp27-cp27mu-linux_x86_64.whl <br/> pip install torchvision <br/><br/> # if the above command does not\ work, then you have python 2.7 UCS2, use this command <br/> pip install http://download.pytorch.org/whl/cu80/torch-0.4.1-cp27-cp27m-linux_x86_64.whl',
        
        'pip,linux,cuda9.0,python2.7': 'pip install torch torchvision',
        
        'pip,linux,cuda9.2,python2.7': 'pip install http://download.pytorch.org/whl/cu92/torch-0.4.1-cp27-cp27mu-linux_x86_64.whl <br/> pip install torchvision <br/><br/> # if the above command does not\ work, then you have python 2.7 UCS2, use this command <br/> pip install http://download.pytorch.org/whl/cu92/torch-0.4.1-cp27-cp27m-linux_x86_64.whl',
        
        'pip,linux,cudanone,python3.5': 'pip3 install http://download.pytorch.org/whl/cpu/torch-0.4.1-cp35-cp35m-linux_x86_64.whl <br/> pip3 install torchvision',
        
        'pip,linux,cuda8,python3.5': 'pip3 install http://download.pytorch.org/whl/cu80/torch-0.4.1-cp35-cp35m-linux_x86_64.whl <br/> pip3 install torchvision',
        
        'pip,linux,cuda9.0,python3.5': 'pip3 install torch torchvision',
        
        'pip,linux,cuda9.2,python3.5': 'pip3 install http://download.pytorch.org/whl/cu92/torch-0.4.1-cp35-cp35m-linux_x86_64.whl <br/> pip3 install torchvision',
        
        'pip,linux,cudanone,python3.6': 'pip3 install http://download.pytorch.org/whl/cpu/torch-0.4.1-cp36-cp36m-linux_x86_64.whl <br/> pip3 install torchvision',
        
        'pip,linux,cuda8,python3.6': 'pip3 install http://download.pytorch.org/whl/cu80/torch-0.4.1-cp36-cp36m-linux_x86_64.whl <br/> pip3 install torchvision',
        
        'pip,linux,cuda9.0,python3.6': 'pip3 install torch torchvision',
        
        'pip,linux,cuda9.2,python3.6': 'pip3 install http://download.pytorch.org/whl/cu92/torch-0.4.1-cp36-cp36m-linux_x86_64.whl <br/> pip3 install torchvision',
        
        'pip,linux,cudanone,python3.7': 'pip3 install http://download.pytorch.org/whl/cpu/torch-0.4.1.post2-cp37-cp37m-linux_x86_64.whl <br/> pip3 install torchvision',
        
        'pip,linux,cuda8,python3.7': 'pip3 install http://download.pytorch.org/whl/cu80/torch-0.4.1.post2-cp37-cp37m-linux_x86_64.whl <br/> pip3 install torchvision',
        
        'pip,linux,cuda9.0,python3.7': 'pip3 install torch torchvision',
        
        'pip,linux,cuda9.2,python3.7': 'pip3 install http://download.pytorch.org/whl/cu92/torch-0.4.1.post2-cp37-cp37m-linux_x86_64.whl <br/> pip3 install torchvision',
        
        'pip,windows,cudanone,python2.7': '# PyTorch does not support Python 2.7 on Windows. Please install with Python 3.',
        
        'pip,windows,cuda8,python2.7': '# PyTorch does not support Python 2.7 on Windows. Please install with Python 3.',
        
        'pip,windows,cuda9.0,python2.7': '# PyTorch does not support Python 2.7 on Windows. Please install with Python 3.',
        
        'pip,windows,cuda9.2,python2.7': '# PyTorch does not support Python 2.7 on Windows. Please install with Python 3.',
        
        'pip,windows,cudanone,python3.5': 'pip3 install http://download.pytorch.org/whl/cpu/torch-0.4.1-cp35-cp35m-win_amd64.whl <br/> pip3 install torchvision',
        
        'pip,windows,cuda8,python3.5': 'pip3 install http://download.pytorch.org/whl/cu80/torch-0.4.1-cp35-cp35m-win_amd64.whl <br/> pip3 install torchvision',
        
        'pip,windows,cuda9.0,python3.5': 'pip3 install http://download.pytorch.org/whl/cu90/torch-0.4.1-cp35-cp35m-win_amd64.whl <br/> pip3 install torchvision',
        
        'pip,windows,cuda9.2,python3.5': 'pip3 install http://download.pytorch.org/whl/cu92/torch-0.4.1-cp35-cp35m-win_amd64.whl <br/> pip3 install torchvision',
        
        'pip,windows,cudanone,python3.6': 'pip3 install http://download.pytorch.org/whl/cpu/torch-0.4.1-cp36-cp36m-win_amd64.whl <br/> pip3 install torchvision',
        
        'pip,windows,cuda8,python3.6': 'pip3 install http://download.pytorch.org/whl/cu80/torch-0.4.1-cp36-cp36m-win_amd64.whl <br/> pip3 install torchvision',
        
        'pip,windows,cuda9.0,python3.6': 'pip3 install http://download.pytorch.org/whl/cu90/torch-0.4.1-cp36-cp36m-win_amd64.whl <br/> pip3 install torchvision',
        
        'pip,windows,cuda9.2,python3.6': 'pip3 install http://download.pytorch.org/whl/cu92/torch-0.4.1-cp36-cp36m-win_amd64.whl <br/> pip3 install torchvision',
        
        'pip,windows,cudanone,python3.7': 'pip3 install http://download.pytorch.org/whl/cpu/torch-0.4.1-cp37-cp37m-win_amd64.whl <br/> pip3 install torchvision',
        
        'pip,windows,cuda8,python3.7': 'pip3 install http://download.pytorch.org/whl/cu80/torch-0.4.1-cp37-cp37m-win_amd64.whl <br/> pip3 install torchvision',
        
        'pip,windows,cuda9.0,python3.7': 'pip3 install http://download.pytorch.org/whl/cu90/torch-0.4.1-cp37-cp37m-win_amd64.whl <br/> pip3 install torchvision',
        
        'pip,windows,cuda9.2,python3.7': 'pip3 install http://download.pytorch.org/whl/cu92/torch-0.4.1-cp37-cp37m-win_amd64.whl <br/> pip3 install torchvision',
    

2) Tensorflow 安装

(G:\ProgramData\Anaconda3) C:\Users\lenovo>pip install --upgrade --ignore-installed tensorflow
Collecting tensorflow
  Using cached https://files.pythonhosted.org/packages/0e/2a/c3fe6035f0a8726e5b210680af3ccaf826f4a64ce7306e57017aba749447/tensorflow-1.10.0-cp36-cp36m-win_amd64.whl
Collecting grpcio>=1.8.6 (from tensorflow)
  Using cached https://files.pythonhosted.org/packages/0e/13/43a98e233716f1d9846ca65322b065443af5ea1aed5f631e240d231174c0/grpcio-1.15.0-cp36-cp36m-win_amd64.whl
Collecting six>=1.10.0 (from tensorflow)
  Using cached https://files.pythonhosted.org/packages/67/4b/141a581104b1f6397bfa78ac9d43d8ad29a7ca43ea90a2d863fe3056e86a/six-1.11.0-py2.py3-none-any.whl
Collecting gast>=0.2.0 (from tensorflow)
Collecting numpy<=1.14.5,>=1.13.3 (from tensorflow)
  Using cached https://files.pythonhosted.org/packages/0d/b7/0c804e0bcba6505f8392d042d5e333a5e06f308e019517111fbc7767a0bc/numpy-1.14.5-cp36-none-win_amd64.whl
Collecting setuptools<=39.1.0 (from tensorflow)
  Using cached https://files.pythonhosted.org/packages/8c/10/79282747f9169f21c053c562a0baa21815a8c7879be97abd930dbcf862e8/setuptools-39.1.0-py2.py3-none-any.whl
Collecting tensorboard<1.11.0,>=1.10.0 (from tensorflow)
  Using cached https://files.pythonhosted.org/packages/c6/17/ecd918a004f297955c30b4fffbea100b1606c225dbf0443264012773c3ff/tensorboard-1.10.0-py3-none-any.whl
Collecting termcolor>=1.1.0 (from tensorflow)
Collecting absl-py>=0.1.6 (from tensorflow)
Collecting astor>=0.6.0 (from tensorflow)
  Using cached https://files.pythonhosted.org/packages/35/6b/11530768cac581a12952a2aad00e1526b89d242d0b9f59534ef6e6a1752f/astor-0.7.1-py2.py3-none-any.whl
Collecting wheel>=0.26 (from tensorflow)
  Using cached https://files.pythonhosted.org/packages/81/30/e935244ca6165187ae8be876b6316ae201b71485538ffac1d718843025a9/wheel-0.31.1-py2.py3-none-any.whl
Collecting protobuf>=3.6.0 (from tensorflow)
  Using cached https://files.pythonhosted.org/packages/e8/df/d606d07cff0fc8d22abcc54006c0247002d11a7f2d218eb008d48e76851d/protobuf-3.6.1-cp36-cp36m-win_amd64.whl
Collecting werkzeug>=0.11.10 (from tensorboard<1.11.0,>=1.10.0->tensorflow)
  Using cached https://files.pythonhosted.org/packages/20/c4/12e3e56473e52375aa29c4764e70d1b8f3efa6682bef8d0aae04fe335243/Werkzeug-0.14.1-py2.py3-none-any.whl
Collecting markdown>=2.6.8 (from tensorboard<1.11.0,>=1.10.0->tensorflow)
  Using cached https://files.pythonhosted.org/packages/6d/7d/488b90f470b96531a3f5788cf12a93332f543dbab13c423a5e7ce96a0493/Markdown-2.6.11-py2.py3-none-any.whl
distributed 1.21.8 requires msgpack, which is not installed.
Installing collected packages: six, grpcio, gast, numpy, setuptools, wheel, protobuf, werkzeug, markdown, tensorboard, termcolor, absl-py, astor, tensorflow
Could not install packages due to an EnvironmentError: [WinError 5] 拒绝访问。: 'G:\\ProgramData\\Anaconda3\\Lib\\site-packages\\numpy\\core\\multiarray.cp36-win_amd64.pyd'
Consider using the `--user` option or check the permissions.

You are using pip version 10.0.1, however version 18.0 is available.
You should consider upgrading via the 'python -m pip install --upgrade pip' command.

报错,加上  --user 参数重新安装:

(G:\ProgramData\Anaconda3) C:\Users\lenovo>pip install --upgrade --ignore-installed tensorflow --user
Collecting tensorflow
  Using cached https://files.pythonhosted.org/packages/0e/2a/c3fe6035f0a8726e5b210680af3ccaf826f4a64ce7306e57017aba749447/tensorflow-1.10.0-cp36-cp36m-win_amd64.whl
Collecting setuptools<=39.1.0 (from tensorflow)
  Using cached https://files.pythonhosted.org/packages/8c/10/79282747f9169f21c053c562a0baa21815a8c7879be97abd930dbcf862e8/setuptools-39.1.0-py2.py3-none-any.whl
Collecting astor>=0.6.0 (from tensorflow)
  Using cached https://files.pythonhosted.org/packages/35/6b/11530768cac581a12952a2aad00e1526b89d242d0b9f59534ef6e6a1752f/astor-0.7.1-py2.py3-none-any.whl
Collecting gast>=0.2.0 (from tensorflow)
Collecting termcolor>=1.1.0 (from tensorflow)
Collecting wheel>=0.26 (from tensorflow)
  Using cached https://files.pythonhosted.org/packages/81/30/e935244ca6165187ae8be876b6316ae201b71485538ffac1d718843025a9/wheel-0.31.1-py2.py3-none-any.whl
Collecting grpcio>=1.8.6 (from tensorflow)
  Using cached https://files.pythonhosted.org/packages/0e/13/43a98e233716f1d9846ca65322b065443af5ea1aed5f631e240d231174c0/grpcio-1.15.0-cp36-cp36m-win_amd64.whl
Collecting protobuf>=3.6.0 (from tensorflow)
  Using cached https://files.pythonhosted.org/packages/e8/df/d606d07cff0fc8d22abcc54006c0247002d11a7f2d218eb008d48e76851d/protobuf-3.6.1-cp36-cp36m-win_amd64.whl
Collecting numpy<=1.14.5,>=1.13.3 (from tensorflow)
  Using cached https://files.pythonhosted.org/packages/0d/b7/0c804e0bcba6505f8392d042d5e333a5e06f308e019517111fbc7767a0bc/numpy-1.14.5-cp36-none-win_amd64.whl
Collecting six>=1.10.0 (from tensorflow)
  Using cached https://files.pythonhosted.org/packages/67/4b/141a581104b1f6397bfa78ac9d43d8ad29a7ca43ea90a2d863fe3056e86a/six-1.11.0-py2.py3-none-any.whl
Collecting tensorboard<1.11.0,>=1.10.0 (from tensorflow)
  Using cached https://files.pythonhosted.org/packages/c6/17/ecd918a004f297955c30b4fffbea100b1606c225dbf0443264012773c3ff/tensorboard-1.10.0-py3-none-any.whl
Collecting absl-py>=0.1.6 (from tensorflow)
Collecting markdown>=2.6.8 (from tensorboard<1.11.0,>=1.10.0->tensorflow)
  Using cached https://files.pythonhosted.org/packages/6d/7d/488b90f470b96531a3f5788cf12a93332f543dbab13c423a5e7ce96a0493/Markdown-2.6.11-py2.py3-none-any.whl
Collecting werkzeug>=0.11.10 (from tensorboard<1.11.0,>=1.10.0->tensorflow)
  Using cached https://files.pythonhosted.org/packages/20/c4/12e3e56473e52375aa29c4764e70d1b8f3efa6682bef8d0aae04fe335243/Werkzeug-0.14.1-py2.py3-none-any.whl
distributed 1.21.8 requires msgpack, which is not installed.
Installing collected packages: setuptools, astor, gast, termcolor, wheel, six, grpcio, protobuf, numpy, markdown, werkzeug, tensorboard, absl-py, tensorflow
  The script wheel.exe is installed in 'C:\Users\lenovo\AppData\Roaming\Python\Python36\Scripts' which is not on PATH.
  Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
  The script markdown_py.exe is installed in 'C:\Users\lenovo\AppData\Roaming\Python\Python36\Scripts' which is not on PATH.
  Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
  The script tensorboard.exe is installed in 'C:\Users\lenovo\AppData\Roaming\Python\Python36\Scripts' which is not on PATH.
  Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
  The scripts freeze_graph.exe, saved_model_cli.exe, tensorboard.exe, tflite_convert.exe, toco.exe and toco_from_protos.exe are installed in 'C:\Users\lenovo\AppData\Roaming\Python\Python36\Scripts' which is not on PATH.
  Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
Successfully installed absl-py-0.4.1 astor-0.7.1 gast-0.2.0 grpcio-1.15.0 markdown-2.6.11 numpy-1.14.5 protobuf-3.6.1 setuptools-39.1.0 six-1.11.0 tensorboard-1.10.0 tensorflow-1.10.0 termcolor-1.1.0 werkzeug-0.14.1 wheel-0.31.1
You are using pip version 10.0.1, however version 18.0 is available.
You should consider upgrading via the 'python -m pip install --upgrade pip' command.

TensorFlow的库在pip list里面可以查询到,但导入报错。 

>>> import tensorflow
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'tensorflow'

 安装msgpack-python 。

pip install msgpack-python
(G:\ProgramData\Anaconda3) C:\Users\lenovo>pip install msgpack-python
Requirement already satisfied: msgpack-python in g:\programdata\anaconda3\lib\site-packages (0.5.6)

以windows系统管理员身份打开cmd命令行工具,重新安装tensorflow:

将C:\Users\lenovo\AppData\Roaming\Python\Python36\Scripts 加入到windows path路径。

C:\WINDOWS\system32>pip install --upgrade --ignore-installed tensorflow --user
Collecting tensorflow
  Using cached https://files.pythonhosted.org/packages/0e/2a/c3fe6035f0a8726e5b210680af3ccaf826f4a64ce7306e57017aba749447/tensorflow-1.10.0-cp36-cp36m-win_amd64.whl
Collecting absl-py>=0.1.6 (from tensorflow)
Collecting protobuf>=3.6.0 (from tensorflow)
  Using cached https://files.pythonhosted.org/packages/e8/df/d606d07cff0fc8d22abcc54006c0247002d11a7f2d218eb008d48e76851d/protobuf-3.6.1-cp36-cp36m-win_amd64.whl
Collecting six>=1.10.0 (from tensorflow)
  Using cached https://files.pythonhosted.org/packages/67/4b/141a581104b1f6397bfa78ac9d43d8ad29a7ca43ea90a2d863fe3056e86a/six-1.11.0-py2.py3-none-any.whl
Collecting astor>=0.6.0 (from tensorflow)
  Using cached https://files.pythonhosted.org/packages/35/6b/11530768cac581a12952a2aad00e1526b89d242d0b9f59534ef6e6a1752f/astor-0.7.1-py2.py3-none-any.whl
Collecting tensorboard<1.11.0,>=1.10.0 (from tensorflow)
  Using cached https://files.pythonhosted.org/packages/c6/17/ecd918a004f297955c30b4fffbea100b1606c225dbf0443264012773c3ff/tensorboard-1.10.0-py3-none-any.whl
Collecting setuptools<=39.1.0 (from tensorflow)
  Using cached https://files.pythonhosted.org/packages/8c/10/79282747f9169f21c053c562a0baa21815a8c7879be97abd930dbcf862e8/setuptools-39.1.0-py2.py3-none-any.whl
Collecting wheel>=0.26 (from tensorflow)
  Using cached https://files.pythonhosted.org/packages/81/30/e935244ca6165187ae8be876b6316ae201b71485538ffac1d718843025a9/wheel-0.31.1-py2.py3-none-any.whl
Collecting numpy<=1.14.5,>=1.13.3 (from tensorflow)
  Using cached https://files.pythonhosted.org/packages/0d/b7/0c804e0bcba6505f8392d042d5e333a5e06f308e019517111fbc7767a0bc/numpy-1.14.5-cp36-none-win_amd64.whl
Collecting termcolor>=1.1.0 (from tensorflow)
Collecting grpcio>=1.8.6 (from tensorflow)
  Using cached https://files.pythonhosted.org/packages/0e/13/43a98e233716f1d9846ca65322b065443af5ea1aed5f631e240d231174c0/grpcio-1.15.0-cp36-cp36m-win_amd64.whl
Collecting gast>=0.2.0 (from tensorflow)
Collecting markdown>=2.6.8 (from tensorboard<1.11.0,>=1.10.0->tensorflow)
  Using cached https://files.pythonhosted.org/packages/6d/7d/488b90f470b96531a3f5788cf12a93332f543dbab13c423a5e7ce96a0493/Markdown-2.6.11-py2.py3-none-any.whl
Collecting werkzeug>=0.11.10 (from tensorboard<1.11.0,>=1.10.0->tensorflow)
  Using cached https://files.pythonhosted.org/packages/20/c4/12e3e56473e52375aa29c4764e70d1b8f3efa6682bef8d0aae04fe335243/Werkzeug-0.14.1-py2.py3-none-any.whl
Installing collected packages: six, absl-py, setuptools, protobuf, astor, markdown, numpy, wheel, werkzeug, tensorboard, termcolor, grpcio, gast, tensorflow
Successfully installed absl-py-0.4.1 astor-0.7.1 gast-0.2.0 grpcio-1.15.0 markdown-2.6.11 numpy-1.14.5 protobuf-3.6.1 setuptools-39.1.0 six-1.11.0 tensorboard-1.10.0 tensorflow-1.10.0 termcolor-1.1.0 werkzeug-0.14.1 wheel-0.31.1

C:\WINDOWS\system32>

导入tensorflow成功。

>>> import tensorflow
>>>

 

来源:未知

声明

本文内容仅代表作者观点,或转载于其他网站,本站不以此文作为商业用途
如有涉及侵权,请联系本站进行删除
转载本站原创文章,请注明来源及作者。