【问题标题】:How to import a specific version of tensorflow?如何导入特定版本的 tensorflow?
【发布时间】:2019-05-30 01:27:43
【问题描述】:

我想使用安装在我的 virtualenv 中的 tensorflow 版本 1.0.0

我正在我的 jupyter notebook 中导入 tensorflow,但全局 tensorflow 版本只是被导入。

如何将tensorflow的版本导入到我安装在virtualenv中的jupyter notebook中

【问题讨论】:

  • 你应该在你的 virtualenv 中只安装了一个版本的 TensorFlow。如果您在那里安装了一个版本并且您看到与 Python 解释器不同的版本,则可能是您正在运行全局解释器,而不是来自 virtualenv 的解释器。如果您使用的是 Jupyter Notebook(或 IPython,或解释器的任何其他接口),请确保您使用的是安装在 virtualenv 中的那个(也就是说,在您的 virtualenv 中安装 Jupyter notebook 并从那里运行它)。
  • 谢谢@jdehesa。现在它正在工作。我在 global env 中运行 jupyter notebook,也就是说,我无法使用安装在 virtualenv 中的那个。

标签: tensorflow jupyter-notebook virtualenv


【解决方案1】:

为了社区的利益,即使它出现在评论部分(感谢@jdehesa),也在这里提供解决方案(回答部分)。

当我们有多个Virtual Environments 并且每个Virtual Environment 都有不同版本的Tensorflow 时,为了使用特定的Tensorflow Version,我们必须激活各自的@987654326 @。

激活Virtual Environment 使用Conda 不同Operating Systems 的命令如下所示:

# Activate the Virtual Environment. Conda Version > 4.6 and Windows OS
conda activate TF_2_VE

# Activating Virtual Environment, Conda Version < 4.6 and Windows OS
activate TF_2_VE

# Activating Virtual Environment, Conda Version < 4.6 and Linux and Mac OS
source activate TF_2_VE

要了解如何使用Python激活Virtual Environment,请参阅此Stack Overflow Issue

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-01-08
    • 2020-12-13
    • 1970-01-01
    • 2018-01-07
    相关资源
    最近更新 更多