简体   繁体   English

Python 使用与 Conda 环境不同的 Tensorflow 版本

[英]Python using different Tensorflow version than Conda environment

I installed tensorflow with pip.我用 pip 安装了 tensorflow。 When I check my tensorflow version inside the conda environment it shows as 2.7.0 as I want it to be.当我在 conda 环境中检查我的 tensorflow 版本时,它显示为我想要的 2.7.0。 However when I check it inside python on the same environment, I get 2.6.0.但是,当我在同一环境中的 python 中检查它时,我得到 2.6.0。 How can I change this so that in both cases I get 2.7.0?我怎样才能改变它,以便在这两种情况下我都得到 2.7.0? I already tried uninstalling and reinstalling tensorflow inside the environment and upgrading it with pip.我已经尝试在环境中卸载并重新安装 tensorflow 并使用 pip 对其进行升级。

(dataset2vec) C:\Users\sozen>pip show tensorflow
Name: tensorflow
Version: 2.7.0
Summary: TensorFlow is an open source machine learning framework for everyone.
Home-page: https://www.tensorflow.org/
Author: Google Inc.
Author-email: packages@tensorflow.org
License: Apache 2.0
Location: c:\users\sozen\anaconda3\envs\dataset2vec\lib\site-packages
Requires: termcolor, numpy, grpcio, gast, protobuf, absl-py, h5py, typing-extensions, six, tensorflow-io-gcs-filesystem, google-pasta, flatbuffers, tensorboard, keras, wrapt, wheel, keras-preprocessing, libclang, tensorflow-estimator, opt-einsum, astunparse
Required-by: ismlldataset

(dataset2vec) C:\Users\sozen>pip install --upgrade tensorflow
Requirement already satisfied: tensorflow in c:\users\sozen\anaconda3\envs\dataset2vec\lib\site-packages (2.7.0)
Requirement already satisfied: gast<0.5.0,>=0.2.1 in c:\users\sozen\anaconda3\envs\dataset2vec\lib\site-packages (from tensorflow) (0.4.0)

(dataset2vec) C:\Users\sozen>python -c "import tensorflow as tf;print(tf.__version__)"
2.6.0

Cheers干杯

I don't know exactly what the problem was but I created a new environment directly installing tensorflow during creation and inside that environment it still used 2.6.0 with python.我不知道到底是什么问题,但我创建了一个新环境,在创建过程中直接安装 tensorflow,在该环境中它仍然使用 2.6.0 和 python。 Then I forced install 2.7.0 and it magically worked!然后我强制安装 2.7.0,它神奇地工作了!

Here's a list of the commands I used:这是我使用的命令的列表:

conda activate tensorTest
python --version
python -c "import tensorflow as tf;print(tf.__version__)"
pip install tensorflow
python -c "import tensorflow as tf;print(tf.__version__)"
>>Still showed 2.6.0
pip install tensorflow==2.7.0
python -c "import tensorflow as tf;print(tf.__version__)"
>>2.7.0!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM