2

为了将存储在 .csv 文件中的文本字符串提供给 Google 的命名实体提取器,我想将 Google NLP API 和 pandas 一起使用。我目前正在使用 conda 来管理我的 python 环境。

这些是我采取的步骤:

第 1 部分:在 conda 环境中安装 google-cloud-language

conda create —n myenv
conda activate myenv
pip install google-cloud-language

运行示例程序:

python language_entities_text.py

输出:

Representative name for the entity: California
Entity type: LOCATION
Salience score: 1.0
wikipedia_url: https://en.wikipedia.org/wiki/California
mid: /m/01n7q
Mention text: California
Mention type: PROPER
Mention text: state
Mention type: COMMON
Language of the text: en

到目前为止,一切都很好。谷歌的示例程序有效

第 2 部分:安装 pandas 并运行相同的程序

conda install pandas

或者

pip install pandas

运行相同的程序:

python language_entities_text.py

使用 conda 或 pip 安装 pandas 并运行相同的程序后,出现错误。

错误信息:

"Traceback (most recent call last):
  File "language_entities_text.py", line 28, in <module>
    from google.cloud import language_v1
ModuleNotFoundError: No module named 'google'

到底是怎么回事?google-cloud-language 和 pandas 之间有冲突吗?如何让两个库一起工作?理想情况下,我想继续使用 conda,因为这是我熟悉的,但 conda 是问题吗?

4

0 回答 0