引言:
python与tensorflow的版本如果不对应,会报错,numpy等包的版本不对应也会报错。经实测,摸索出一套对应关系,CPU和GPU版本都适用:
python | 3.9.18 |
tensorflow | 2.6.0 |
numpy | 1.19.5 |
matplotlib | 3.5.2 |
pillow | 10.1.0 |
scikit-learn | 1.3.2 |
scipy | 1.10.0rc1 |
pandas | 1.3.1 |
一、在anaconda.navigator环境管理中创建Tensorflow2.6的Python环境
选择“Enviroments”,点击"Create",
新建一个环境,随便命名,python版本选择3.9.18,点击create
二、按顺序安装包:
2.1 安装numpy
pip install numpy==1.19.5
Successfully installed numpy-1.19.5
2.2 安装matplotlib
pip install matplotlib==3.5.2
Successfully installed cycler-0.12.1 fonttools-4.44.0 kiwisolver-1.4.5 matplotlib-3.5.2 packaging-23.2 pillow-10.1.0 pyparsing-3.1.1 python-dateutil-2.8.2 six-1.16.0
2.3 安装scikit-learn
pip install scikit-learn==1.3.2
Successfully uninstalled numpy-1.19.5
Successfully installed joblib-1.3.2 numpy-1.26.1 scikit-learn-1.3.2 scipy-1.11.3 threadpoolctl-3.2.0
pip uninstall scipy
pip install scipy==1.10.0rc1
Successfully installed scipy-1.10.0rc1
2.4 安装pandas
pip install pandas==1.3.4
Successfully installed pandas-1.3.4 pytz-2023.3.post1
第三步,安装tensorflow
pip install tensorflow==2.6.0
Successfully installed MarkupSafe-2.1.3 absl-py-0.15.0 astunparse-1.6.3 cachetools-5.3.2 certifi-2023.7.22 charset-normalizer-3.3.2 clang-5.0 flatbuffers-1.12 gast-0.4.0 google-auth-2.23.4 google-auth-oauthlib-1.1.0 google-pasta-0.2.0 grpcio-1.59.2 h5py-3.1.0 idna-3.4 importlib-metadata-6.8.0 keras-2.15.0 keras-preprocessing-1.1.2 markdown-3.5.1 numpy-1.19.5 oauthlib-3.2.2 opt-einsum-3.3.0 protobuf-4.23.4 pyasn1-0.5.0 pyasn1-modules-0.3.0 requests-2.31.0 requests-oauthlib-1.3.1 rsa-4.9 six-1.15.0 tensorboard-2.15.1 tensorboard-data-server-0.7.2 tensorflow-2.6.0 tensorflow-estimator-2.15.0 termcolor-1.1.0 typing-extensions-3.7.4.3 urllib3-2.0.7 werkzeug-3.0.1 wrapt-1.12.1 zipp-3.17.0