如何使用 anaconda 为 python 安装 google.cloud automl_v1beta1?

How to install google.cloud automl_v1beta1 for python using anaconda?

Google Cloud AutoML 有 python 检测示例代码,但我在导入这些模块时出错

from google.cloud import automl_v1beta1
from google.cloud.automl_v1beta1.proto import service_pb2

它说 cannot import name automl_v1beta1。我知道这是一个常见问题,互联网上有很多解决方案,但目前没有任何效果。我在 Anaconda 环境中使用 Windows 10 和 运行 python 2.7。

我尝试了这些,但没有任何效果:

conda install -c conda-forge google-cloud-sdk
conda install -c conda-forge google-cloud-storage 
python -m pip install google-cloud
pip install google-cloud-automl

您可以在 Jupyter notebook cell 中安装包,希望对您有用。

我刚刚解决了它,这是一个非常简单的问题。我使用以下命令重新安装 google-cloud-automl 并正常工作。

pip.exe install google-cloud-automl

为什么我上次试过没有用?这是因为我没有 运行 anaconda 提示作为 管理员 。原因是在安装 google-cloud-automl 时,它会卸载像 future 这样的弃用项目,如下所示:

Found existing installation: futures 3.1.1
    DEPRECATION: Uninstalling a distutils installed project (futures) has been deprecated and will be removed in a future version. This is due to the fact that uninstalling a distutils project will only partially uninstall the project.
    Uninstalling futures-3.1.1:
      Successfully uninstalled futures-3.1.1

Future 只有在我 运行 作为管理员执行命令时才能成功删除。上次它抛出了我没有意识到的身份验证错误,因此重新安装过程停止了。希望它能在未来帮助一些人。