【问题标题】:Python using different Tensorflow version than Conda environmentPython 使用与 Conda 环境不同的 Tensorflow 版本
【发布时间】:2022-01-12 23:05:56
【问题描述】:

我用 pip 安装了 tensorflow。当我在 conda 环境中检查我的 tensorflow 版本时,它显示为我想要的 2.7.0。但是,当我在同一环境中的 python 中检查它时,我得到 2.6.0。我怎样才能改变它,以便在这两种情况下我都得到 2.7.0?我已经尝试在环境中卸载并重新安装 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

干杯

【问题讨论】:

    标签: python tensorflow pip conda


    【解决方案1】:

    我不知道到底是什么问题,但我创建了一个新环境,在创建过程中直接安装 tensorflow,在该环境中它仍然使用 2.6.0 和 python。然后我强制安装 2.7.0,它神奇地工作了!

    这是我使用的命令列表:

    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!
    

    【讨论】:

    • 不要混合使用 pip 和 conda 命令!听起来你在创建 env 时 conda 安装了 tensorflow,然后在其上安装了 pip
    • 是的!我不知道我必须避免混合 conda 和 pip 命令。谢谢!
    猜你喜欢
    • 2020-03-22
    • 1970-01-01
    • 2022-08-21
    • 2021-09-20
    • 2021-09-29
    • 1970-01-01
    • 2021-10-28
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多