简体   繁体   English

如何在 Mac M1 上安装 Google Cloud DLP?

[英]How to install Google Cloud DLP on Mac M1?

I am trying to download Google Cloud DLP on my Mac M1 running macOS Monterey.我正在尝试在运行 macOS Monterey 的 Mac M1 上下载 Google Cloud DLP。 I am using Python 3.10.4 and pip 22.0.4.我正在使用 Python 3.10.4 和 pip 22.0.4。

I first tried using pip install google-cloud-dlp , but got an error when I went to import it that I have the wrong architecture (arm instead of x86-64 – hence M1 error).我首先尝试使用pip install google-cloud-dlp ,但是当我导入它时出现错误,我的架构错误(arm 而不是 x86-64 - 因此出现 M1 错误)。

I then uninstalled DLP and followed the advice of a StackOverflow post to download the library directly from GitHub. I did this, navigated to the directory, and ran sudo python3 setup.py install .然后我卸载了 DLP 并按照 StackOverflow 帖子的建议直接从 GitHub 下载库。我这样做了,导航到目录,然后运行sudo python3 setup.py install

Now, when I try to import the library, I get the error:现在,当我尝试导入库时,出现错误:

---------------------------------------------------------------------------
ModuleNotFoundError                       Traceback (most recent call last)
Input In [57], in <cell line: 1>()
----> 1 import google.cloud.dlp

ModuleNotFoundError: No module named 'google.cloud.dlp'

This is odd because when I run pip list I get this in the output:这很奇怪,因为当我运行pip list时,我在 output 中得到了这个:

google-api-core          2.7.2
google-auth              2.6.6
google-cloud-dlp         3.6.2
googleapis-common-protos 1.56.0

Now, when I run pip install google-cloud-dlp , I get a bunch of "Requirement already satisfied" messages, yet when I try to import, I get a ModuleNotFoundError.现在,当我运行pip install google-cloud-dlp时,我收到一堆“要求已满足”消息,但当我尝试导入时,我收到 ModuleNotFoundError。

I have tried importing in Atom, VSCode, and Jupyter-Notebook, and still get a ModuleNotFoundError.我已经尝试在 Atom、VSCode 和 Jupyter-Notebook 中导入,但仍然出现 ModuleNotFoundError。 I feel dumb asking this question because it seems like it would be an easy fix, but any help is appreciated.我觉得问这个问题很愚蠢,因为这似乎很容易解决,但我们将不胜感激。

One potential issue is that you have multiple python versions installed.一个潜在的问题是您安装了多个 python 版本。 Is it possible that the script ran under in a different Python environment than the one used to print the installed versions?脚本是否有可能在与用于打印已安装版本的环境不同的 Python 环境下运行?

Could you try following these steps?您可以尝试按照这些步骤操作吗?

  1. Create virtualenv.创建虚拟环境。
python3 -m venv env
source env/bin/activate
  1. Install google-cloud-dlp .安装google-cloud-dlp
pip install google-cloud-dlp
  1. Run code.运行代码。
$ python3
>>>import google.cloud.dlp
>>>

If you're still having trouble, try the steps on another environment like Cloud Shell to rule out an issue with your specific environment.如果您仍然遇到问题,请尝试在其他环境(如Cloud Shell )上执行这些步骤,以排除您的特定环境存在的问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM