Tensorflow安装

一、设置清华源:

Anaconda 镜像使用帮助

点此进入

1.找到名为 .condarc 的文件(一般在用户目录下)

2.覆盖文件内容

channels:
  - defaults
show_channel_urls: true
default_channels:
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/r
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/msys2
custom_channels:
  conda-forge: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  msys2: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  bioconda: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  menpo: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  pytorch: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  pytorch-lts: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  simpleitk: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud


二、Anaconda prompt中创建虚拟环境:

1.先创建tensorflow2.0.0.yml文件,修改文件中最后一行

prefix: D:\software\Anaconda\envs\tf2        #prefix: 你指定的虚拟环境的路径

文件名:tensorflow2.0.0.yml

name: tf2
channels:
  - defaults
dependencies:
  - _tflow_select=2.2.0=eigen
  - absl-py=0.15.0=pyhd3eb1b0_0
  - aiohttp=3.7.4.post0=py36h2bbff1b_2
  - astor=0.8.1=py36haa95532_0
  - async-timeout=3.0.1=py36haa95532_0
  - attrs=21.4.0=pyhd3eb1b0_0
  - backcall=0.2.0=pyhd3eb1b0_0
  - blas=1.0=mkl
  - blinker=1.4=py36haa95532_0
  - brotlipy=0.7.0=py36h2bbff1b_1003
  - ca-certificates=2022.3.29=haa95532_0
  - cachetools=4.2.2=pyhd3eb1b0_0
  - certifi=2021.5.30=py36haa95532_0
  - cffi=1.14.6=py36h2bbff1b_0
  - chardet=4.0.0=py36haa95532_1003
  - charset-normalizer=2.0.4=pyhd3eb1b0_0
  - click=8.0.3=pyhd3eb1b0_0
  - colorama=0.4.4=pyhd3eb1b0_0
  - cryptography=3.4.7=py36h71e12ea_0
  - cycler=0.11.0=pyhd3eb1b0_0
  - decorator=5.1.1=pyhd3eb1b0_0
  - entrypoints=0.3=py36_0
  - freetype=2.10.4=hd328e21_0
  - gast=0.2.2=py36_0
  - google-auth-oauthlib=0.4.4=pyhd3eb1b0_0
  - google-pasta=0.2.0=pyhd3eb1b0_0
  - grpcio=1.35.0=py36hc60d5dd_0
  - h5py=2.10.0=py36h5e291fa_0
  - hdf5=1.10.4=h7ebc959_0
  - icc_rt=2019.0.0=h0cc432a_1
  - icu=58.2=ha925a31_3
  - idna=3.3=pyhd3eb1b0_0
  - idna_ssl=1.1.0=py36haa95532_0
  - importlib-metadata=4.8.1=py36haa95532_0
  - intel-openmp=2022.0.0=haa95532_3663
  - ipykernel=5.3.4=py36h5ca1d4c_0
  - ipython=7.16.1=py36h5ca1d4c_0
  - ipython_genutils=0.2.0=pyhd3eb1b0_1
  - jedi=0.17.0=py36_0
  - joblib=1.0.1=pyhd3eb1b0_0
  - jpeg=9d=h2bbff1b_0
  - jupyter_client=7.1.2=pyhd3eb1b0_0
  - jupyter_core=4.8.1=py36haa95532_0
  - keras-applications=1.0.8=py_1
  - keras-preprocessing=1.1.2=pyhd3eb1b0_0
  - kiwisolver=1.3.1=py36hd77b12b_0
  - libpng=1.6.37=h2a8f88b_0
  - libprotobuf=3.17.2=h23ce68f_1
  - libtiff=4.2.0=hd0e1b90_0
  - lz4-c=1.9.3=h2bbff1b_1
  - markdown=3.3.4=py36haa95532_0
  - matplotlib=3.3.4=py36haa95532_0
  - matplotlib-base=3.3.4=py36h49ac443_0
  - mkl=2020.2=256
  - mkl-service=2.3.0=py36h196d8e1_0
  - mkl_fft=1.3.0=py36h46781fe_0
  - mkl_random=1.1.1=py36h47e9c7a_0
  - multidict=5.1.0=py36h2bbff1b_2
  - nest-asyncio=1.5.1=pyhd3eb1b0_0
  - numpy=1.19.2=py36hadc3359_0
  - numpy-base=1.19.2=py36ha3acd2a_0
  - oauthlib=3.2.0=pyhd3eb1b0_0
  - olefile=0.46=py36_0
  - openssl=1.1.1n=h2bbff1b_0
  - opt_einsum=3.3.0=pyhd3eb1b0_1
  - pandas=1.1.5=py36hd77b12b_0
  - parso=0.8.3=pyhd3eb1b0_0
  - pickleshare=0.7.5=pyhd3eb1b0_1003
  - pillow=8.3.1=py36h4fa10fc_0
  - pip=21.2.2=py36haa95532_0
  - prompt-toolkit=3.0.20=pyhd3eb1b0_0
  - protobuf=3.17.2=py36hd77b12b_0
  - pyasn1=0.4.8=pyhd3eb1b0_0
  - pyasn1-modules=0.2.8=py_0
  - pycparser=2.21=pyhd3eb1b0_0
  - pygments=2.11.2=pyhd3eb1b0_0
  - pyjwt=2.1.0=py36haa95532_0
  - pyopenssl=21.0.0=pyhd3eb1b0_1
  - pyparsing=3.0.4=pyhd3eb1b0_0
  - pyqt=5.9.2=py36h6538335_2
  - pyreadline=2.1=py36_1
  - pysocks=1.7.1=py36haa95532_0
  - python=3.6.5=h0c2934d_0
  - python-dateutil=2.8.2=pyhd3eb1b0_0
  - pytz=2021.3=pyhd3eb1b0_0
  - pywin32=228=py36hbaba5e8_1
  - pyzmq=22.2.1=py36hd77b12b_1
  - qt=5.9.7=vc14h73c81de_0
  - requests=2.27.1=pyhd3eb1b0_0
  - requests-oauthlib=1.3.0=py_0
  - rsa=4.7.2=pyhd3eb1b0_1
  - scikit-learn=0.24.1=py36hf11a4ad_0
  - scipy=1.5.2=py36h9439919_0
  - seaborn=0.11.2=pyhd3eb1b0_0
  - setuptools=58.0.4=py36haa95532_0
  - sip=4.19.8=py36h6538335_0
  - six=1.16.0=pyhd3eb1b0_1
  - sqlite=3.38.2=h2bbff1b_0
  - tensorboard=2.4.0=pyhc547734_0
  - tensorboard-plugin-wit=1.6.0=py_0
  - tensorflow=2.0.0=eigen_py36h457aea3_0
  - tensorflow-base=2.0.0=eigen_py36h01553b8_0
  - tensorflow-estimator=2.0.0=pyh2649769_0
  - termcolor=1.1.0=py36haa95532_1
  - threadpoolctl=2.2.0=pyh0d69192_0
  - tk=8.6.11=h2bbff1b_0
  - tornado=6.1=py36h2bbff1b_0
  - traitlets=4.3.3=py36haa95532_0
  - typing-extensions=4.1.1=hd3eb1b0_0
  - typing_extensions=4.1.1=pyh06a4308_0
  - urllib3=1.26.8=pyhd3eb1b0_0
  - vc=14.2=h21ff451_1
  - vs2015_runtime=14.27.29016=h5e58377_2
  - wcwidth=0.2.5=pyhd3eb1b0_0
  - werkzeug=0.16.1=py_0
  - wheel=0.37.1=pyhd3eb1b0_0
  - win_inet_pton=1.1.0=py36haa95532_0
  - wincertstore=0.2=py36h7fe50ca_0
  - wrapt=1.12.1=py36he774522_1
  - xz=5.2.5=h62dcd97_0
  - yarl=1.6.3=py36h2bbff1b_0
  - zipp=3.6.0=pyhd3eb1b0_0
#  - zlib=1.2.12=h8cc25b3_0
  - zstd=1.4.9=h19a0ad4_0
  - pip:
    - google-auth==1.35.0
prefix: D:\software\Anaconda\envs\tf2

2. 把tensorflow2.0.0.yml文件放在用户目录下(和.condarc 的文件同一个目录)或着在prompt中cd找到tensorflow2.0.0.yml文件。然后下载环境

conda env create -f tensorflow2.0.0.yml -n tf2

Tensorflow安装_第1张图片


三、进入tf2虚拟环境执行如下安装:

1.进入虚拟环境

conda activate your_envs          # your_envs就是你的虚拟环境名称

Tensorflow安装_第2张图片

2.为不同的虚拟环境设置

conda install ipykernel  


Tensorflow安装_第3张图片

3 运行如下命令使 jupyter notebook 能够识别到环境

python -m ipykernel install --user --name tf2 --display-name "tf2"
注: tf2为当前虚拟环境名称   "tf2"为jupyter notebook中显示的内核名称

  

 四、检测安装

 1.打开jupyter notebook,随便建一个python3

Tensorflow安装_第4张图片

 2.切换kernel

Tensorflow安装_第5张图片

 3.导入

Tensorflow安装_第6张图片

你可能感兴趣的:(tensorflow,人工智能,python)