配置tensorflow环境步骤

创建环境

conda create -n tensorflow_ner python=3.6

安装tensorflow 1.2版本

pip install tensorflow==1.2.0

出错:

Collecting tensorflow==1.2.0
  Cache entry deserialization failed, entry ignored
  Could not fetch URL https://pypi.tuna.tsinghua.edu.cn/simple/tensorflow/: There was a problem confirming the ssl certificate: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:748) - skipping
  Could not find a version that satisfies the requirement tensorflow==1.2.0 (from versions: )
No matching distribution found for tensorflow==1.2.0
You are using pip version 9.0.1, however version 22.3.1 is available.
You should consider upgrading via the 'python -m pip install --upgrade pip' command.

需要升级pip

python -m pip install --upgrade pip

出错:

Cache entry deserialization failed, entry ignored
Could not fetch URL https://pypi.tuna.tsinghua.edu.cn/simple/pip/: There was a problem confirming the ssl certificate: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:748) - skipping
Requirement already up-to-date: pip in d:\anaconda3\envs\tensorflow_ner\lib\site-packages
You are using pip version 9.0.1, however version 22.3.1 is available.
You should consider upgrading via the 'python -m pip install --upgrade pip' command.

清华镜像不中用了,换个豆瓣的

python -m pip install --upgrade pip -i https://pypi.douban.com/simple

成功了!

Cache entry deserialization failed, entry ignored
Cache entry deserialization failed, entry ignored
Collecting pip
  Downloading https://pypi.doubanio.com/packages/a4/6d/6463d49a933f547439d6b5b98b46af8742cc03ae83543e4d7688c2420f8b/pip-21.3.1-py3-none-any.whl (1.7MB)
    100% |████████████████████████████████| 1.7MB 587kB/s
Installing collected packages: pip
  Found existing installation: pip 9.0.1
    Uninstalling pip-9.0.1:
      Successfully uninstalled pip-9.0.1
Successfully installed pip-21.3.1
You are using pip version 21.3.1, however version 22.3.1 is available.
You should consider upgrading via the 'python -m pip install --upgrade pip' command.

继续安装tensorflow

pip install tensorflow==1.2.0

成功:

Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple
Collecting tensorflow==1.2.0
  Downloading https://pypi.tuna.tsinghua.edu.cn/packages/8e/4b/764e86b8b6a61ca49c9f6fb55b4193063f7021e2c1c51cde7bbf228158b4/tensorflow-1.2.0-cp36-cp36m-win_amd64.whl (21.2 MB)
     |████████████████████████████████| 21.2 MB 2.2 MB/s
Collecting markdown==2.2.0
  Downloading https://pypi.tuna.tsinghua.edu.cn/packages/f1/9b/abac7cce338f4d832b9301c978103fd280f7ead4de869f4eb247beeac32b/Markdown-2.2.0.zip (358 kB)
     |████████████████████████████████| 358 kB 86 kB/s
  Preparing metadata (setup.py) ... done
Collecting numpy>=1.11.0
  Using cached https://pypi.tuna.tsinghua.edu.cn/packages/ea/bc/da526221bc111857c7ef39c3af670bbcf5e69c247b0d22e51986f6d0c5c2/numpy-1.19.5-cp36-cp36m-win_amd64.whl (13.2 MB)
Collecting werkzeug>=0.11.10
  Downloading https://pypi.tuna.tsinghua.edu.cn/packages/f4/f3/22afbdb20cc4654b10c98043414a14057cd27fdba9d4ae61cea596000ba2/Werkzeug-2.0.3-py3-none-any.whl (289 kB)
     |████████████████████████████████| 289 kB 1.1 MB/s
Collecting html5lib==0.9999999
  Downloading https://pypi.tuna.tsinghua.edu.cn/packages/ae/ae/bcb60402c60932b32dfaf19bb53870b29eda2cd17551ba5639219fb5ebf9/html5lib-0.9999999.tar.gz (889 kB)
     |████████████████████████████████| 889 kB ...
  Preparing metadata (setup.py) ... done
Collecting backports.weakref==1.0rc1
  Downloading https://pypi.tuna.tsinghua.edu.cn/packages/6a/f7/ae34b6818b603e264f26fe7db2bd07850ce331ce2fde74b266d61f4a2d87/backports.weakref-1.0rc1-py3-none-any.whl (4.3 kB)
Collecting bleach==1.5.0
  Downloading https://pypi.tuna.tsinghua.edu.cn/packages/33/70/86c5fec937ea4964184d4d6c4f0b9551564f821e1c3575907639036d9b90/bleach-1.5.0-py2.py3-none-any.whl (17 kB)
Collecting protobuf>=3.2.0
  Downloading https://pypi.tuna.tsinghua.edu.cn/packages/98/f4/b21be85a824309351356c9a229cf9614d521620e26202a36d5fff2353c37/protobuf-3.19.6-cp36-cp36m-win_amd64.whl (897 kB)
     |████████████████████████████████| 897 kB 211 kB/s
Collecting six>=1.10.0
  Using cached https://pypi.tuna.tsinghua.edu.cn/packages/d9/5a/e7c31adbe875f2abbb91bd84cf2dc52d792b5a01506781dbcf25c91daf11/six-1.16.0-py2.py3-none-any.whl (11 kB)
Requirement already satisfied: wheel>=0.26 in d:\anaconda3\envs\tensorflow_ner\lib\site-packages (from tensorflow==1.2.0) (0.29.0)
Collecting dataclasses
  Downloading https://pypi.tuna.tsinghua.edu.cn/packages/fe/ca/75fac5856ab5cfa51bbbcefa250182e50441074fdc3f803f6e76451fab43/dataclasses-0.8-py3-none-any.whl (19 kB)
Building wheels for collected packages: html5lib, markdown
  Building wheel for html5lib (setup.py) ... done
  Created wheel for html5lib: filename=html5lib-0.9999999-py3-none-any.whl size=111329 sha256=90b7fce64cd4d84b824bbcc4474c055c0e00c921a4cdfc41e505b87ef9122161
  Stored in directory: c:\users\29617\appdata\local\pip\cache\wheels\7c\02\3a\e8d8a152cbeaa48949035c18f805ff56568398f16039483f42
  Building wheel for markdown (setup.py) ... done
  Created wheel for markdown: filename=Markdown-2.2.0-py3-none-any.whl size=136928 sha256=4d620ff747de9cb89c50903a9c36428864da419c8f7097d4682514f5397f163c
  Stored in directory: c:\users\29617\appdata\local\pip\cache\wheels\f6\26\be\ee86f23fada419316735a08c19e9bd2b8c052f438fcc736aab
Successfully built html5lib markdown
Installing collected packages: six, html5lib, dataclasses, werkzeug, protobuf, numpy, markdown, bleach, backports.weakref, tensorflow
Successfully installed backports.weakref-1.0rc1 bleach-1.5.0 dataclasses-0.8 html5lib-0.9999999 markdown-2.2.0 numpy-1.19.5 protobuf-3.19.6 six-1.16.0 tensorflow-1.2.0 werkzeug-2.0.3

验证一下:

(tensorflow_ner) C:\Users\29617>python
Python 3.6.2 |Continuum Analytics, Inc.| (default, Jul 20 2017, 12:30:02) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow as tf
>>> print(tf.__version__)
1.2.0
>>>

以上安装过程参考:
1、TensorFlow的历史版本与对应Python版本
2、tensorflow详细安装教程(Win10, Anaconda,Python3.9)

接下来进行NER的项目过程
打开pycharm,打开相应的项目文件
配置tensorflow环境步骤_第1张图片
配置tensorflow环境步骤_第2张图片
注意到当前环境还是base,需要切换环境
步骤如下:
配置tensorflow环境步骤_第3张图片
配置tensorflow环境步骤_第4张图片
选择python.exe之后一路确定,环境切换结束
如图:
配置tensorflow环境步骤_第5张图片
虽然被挡住了,但问题不大~ 步骤是对的 哈哈

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