【问题标题】:unable to import tensorflow after I pip install in a virtual environment in python在 python 的虚拟环境中安装 pip 后无法导入 tensorflow
【发布时间】:2020-03-19 13:11:40
【问题描述】:

我的 python 版本是 3.7.5。

在 vscode 中,我创建了我的虚拟环境

python -m venv myProj

然后我将我的 python 解释器切换到:python3.7.5 64bit ('myProj':venv)

我安装tensorflow如下:

pip install tensorflow

我可以看到张量流出现在myProj/lib-sitePackages

然后我尝试运行其中有一行'import tensorflow'的python文件 提示如下: (myProj) C:\Users\xxx\Documents\My_Document\myname\myProj>

我收到如下错误:

ImportError: DLL load failed: The specified module could not be found.
Failed to load the native TensorFlow runtime.........

有趣的是,当我在虚拟环境之外执行pip install tensorflow 时,我能够运行 python3.7.5 并导入 tensorflow。

我花了几个小时尝试这个和那个。但是没有成功。 有谁知道为什么会这样?

【问题讨论】:

  • 你好,我想知道这个参考对further troubleshooting是否有帮助如果你在 Windows 中,似乎很多人在 Windows 中经常降级一两个版本。

标签: python tensorflow visual-studio-code


【解决方案1】:

在 anaconda 中运行 tensorflow。 删除并卸载所有现有的python软件并下载anaconda。然后查看如何在anaconda中安装tensorflow和keras的教程。以良好的网速大约需要 20 分钟。 在没有 anaconda 的情况下尝试时,我曾经得到相同的 dll 错误加载模块未找到错误。这些是兼容性问题

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2019-01-08
    • 2018-02-20
    • 1970-01-01
    • 2018-04-19
    • 1970-01-01
    • 1970-01-01
    • 2021-11-01
    相关资源
    最近更新 更多