D:\software\anaconda
D:\software\anaconda\Scripts
D:\software\anaconda\Library\bin
D:\software\anaconda\Library\mingw-w64\bin
C:\Users\dulei>conda -V
conda 4.12.0
tensorflow cpu版本:https://pypi.tuna.tsinghua.edu.cn/simple/tensorflow-cpu/
tensorflow_cpu-2.2.2-cp38-cp38-win_amd64.whl
conda create -n tfpy38 pip python=3.8//创建名字为tfpy38的虚拟环境并安装python3.8
activate tfpy38//激活tfpy38环境 deactivate tfpy38//退出环境
(tfpy38) D:\software\tensorflow>pip install tensorflow_cpu-2.2.2-cp38-cp38-win_amd64.whl
//遇到报错: which is not on PATH.解决:https://zhuanlan.zhihu.com/p/454816609
//tfpy38环境里python版本3.8.13
(tfpy38) C:\WINDOWS\system32>python
Python 3.8.13 (default, Mar 28 2022, 06:59:08) [MSC v.1916 64 bit (AMD64)] :: Anaconda, Inc. on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import os
>>> os.environ['TF_CPP_MIN_LOG_LEVEL'] = '2'
>>> import tensorflow as tf
>>> print(tf.__version__)
//2.2.2
tensorflow_cpu-1.15.0-cp37-cp37m-win_amd64.whl
conda create -n tf115py37 pip python=3.7
//报错InvalidArchiveError:原来安装过,可能是因为之前安装失败残留的文件。手动删除文件或文件夹是没有用的,需要改文件夹权限才可以解决。参考:https://blog.csdn.net/weixin_41693880/article/details/122310125
安装tf1:设置-Anaconda Prompt-python-cd到whl文件的目录位置
activate tf115py37
(tf115py37) D:\software\tensorflow>pip install tensorflow_cpu-1.15.0-cp37-cp37m-win_amd64.whl
python
>>> import tensorflow as tf
>>> import os
>>> os.environ['TF_CPP_MIN_LOG_LEVEL'] = '2'
>>> hello = tf.constant('Hello, TensorFlow!')
>>> sess = tf.Session()
>>> print(sess.run(hello))
输出:b'Hello, TensorFlow!'
报错:TypeError: Descriptors cannot not be created directly.
If this call came from a _pb2.py file, your generated code is out of date and must be regenerated with protoc >= 3.19.0.
If you cannot immediately regenerate your protos, some other possible workarounds are:
1. Downgrade the protobuf package to 3.20.x or lower.
2. Set PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=python (but this will use pure-Python parsing and will be much slower).
解决:https://blog.csdn.net/qq_41650747/article/details/124994674
import tensorflow as tf
print(tf.__version__)
输出2.2.2
//安装
activate tf115py37
pip install keras==2.3.1
//验证
python
import keras
显示Using TensorFlow backend.则说明安装成功,
3. tf1版本安装matplotlib
activate tf115py37
conda install matplotlib
//验证
python
import matplotlib
activate tf115py37//注意:一定要切换到你想要装的环境里
pip install -i https://pypi.douban.com/simple pandas
activate tf115py37
conda install scikit-learn
activate tf115py37
conda install ipykernel # 安装jupyter内核
# 添加虚拟环境到jupyter中 将虚拟环境引用到Jupyter中
python -m ipykernel install --user --name tf115py37 --display-name "Python [conda env:tf115py37]"
Python3的str 默认不是bytes,所以不能decode,只能先encode转为bytes,再decode
>activate tf115py37
>pip install h5py==2.10 --user