在Windows上的Ubuntu上用Bash更新Python库

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了在Windows上的Ubuntu上用Bash更新Python库相关的知识,希望对你有一定的参考价值。

不久前,我创建了一个虚拟环境,可以在Windows上的Ubuntu上使用Bash上的Python tensorflow库。

在该环境中使用pip3 list时,我可以看到安装了版本1.1.0的tensorflow。与此同时,tensorflow 1.5已经被释放。

我正在尝试使用pip3 install tensorflow将tensorflow库更新到新版本。但我只收到“要求已经满足”的消息。

如何在此环境中将tensorflow(和我的其他库发生相同的事情)上传到最新版本?

答案

this question我使用以下python脚本:

import pip
import subprocess
for dist in pip.get_installed_distributions():
    if 'site-packages' in dist.location:
        try:
            subprocess.call(['pip3', 'install', '-U', dist.key])
            print("updated " + dist.key)
        except Exception as exc:
            print(exc)

用python3调用它,它应该升级所有需要更新的包。您可能还想查看其他替代方案。

以上是关于在Windows上的Ubuntu上用Bash更新Python库的主要内容,如果未能解决你的问题,请参考以下文章

如何检查程序是不是在 Windows 上的 Ubuntu 上的 Bash 中运行,而不仅仅是普通的 Ubuntu?

从 bash 脚本检测“Windows 上的 Ubuntu”与本机 Ubuntu [重复]

Windows 10 上的 Bash 和 Ubuntu 终端有啥区别

Windows 10 - Bash(Ubuntu)SU(根密码)[关闭]

在 Windows 上的 Ubuntu bash 上“找不到引用控制台的文件描述符”

在 Windows 上运行 ubuntu 上的 bash 运行 npm 命令给出错误“/usr/bin/env: node: No such file or directory”