首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >ModuleNotFoundError:虽然我正确地安装了它,但没有一个模块名为“googletrans”

ModuleNotFoundError:虽然我正确地安装了它,但没有一个模块名为“googletrans”
EN

Stack Overflow用户
提问于 2022-03-31 07:31:37
回答 2查看 2.3K关注 0票数 3

我正在尝试导入一个googletrans,但是当我试图导入它时,我得到了一个ModuleNotFoundError,尽管我安装了它。

我犯了这个错误

代码语言:javascript
运行
复制
11 #to translate the text data
12 get_ipython().system('pip install googletrans')
---> 13 from googletrans import Translator

ModuleNotFoundError: No module named 'googletrans'

我正在尝试在jupyter笔记本上安装一个带有所有语法的googletrans包

代码语言:javascript
运行
复制
!pip install googletrans
!pip install googletrans==4.0.0-rc1 #to avoid 'NoneType' object has no attribute 'group' error
!pip install googletrans==3.1.0a0 #to avoid 'NoneType' object has no attribute 'group' error

安装完毕后,我尝试导入它

from googletrans import Translator

我犯了这个错误

代码语言:javascript
运行
复制
11 #to translate the text data
12 get_ipython().system('pip install googletrans')
13 from googletrans import Translator

ModuleNotFoundError: No module named 'googletrans'

ModuleNotFoundError:没有名为'googletrans'的模块

但我必须通知您,pip命令的输出是

代码语言:javascript
运行
复制
Collecting googletrans
  Using cached googletrans-3.0.0-py3-none-any.whl
Collecting httpx==0.13.3
  Using cached httpx-0.13.3-py3-none-any.whl (55 kB)
Requirement already satisfied: certifi in c:\programdata\anaconda3\envs\python310\lib\site-packages (from httpx==0.13.3->googletrans) (2021.10.8)
Collecting hstspreload
  Using cached hstspreload-2021.12.1-py3-none-any.whl (1.3 MB)
Requirement already satisfied: sniffio in c:\programdata\anaconda3\envs\python310\lib\site-packages (from httpx==0.13.3->googletrans) (1.2.0)
Requirement already satisfied: rfc3986<2,>=1.3 in c:\programdata\anaconda3\envs\python310\lib\site-packages (from httpx==0.13.3->googletrans) (1.5.0)
Requirement already satisfied: chardet==3.* in c:\programdata\anaconda3\envs\python310\lib\site-packages (from httpx==0.13.3->googletrans) (3.0.4)
Collecting httpcore==0.9.*
  Using cached httpcore-0.9.1-py3-none-any.whl (42 kB)
Collecting idna==2.*
  Using cached idna-2.10-py2.py3-none-any.whl (58 kB)
Collecting h2==3.*
  Using cached h2-3.2.0-py2.py3-none-any.whl (65 kB)
Requirement already satisfied: h11<0.10,>=0.8 in c:\programdata\anaconda3\envs\python310\lib\site-packages (from httpcore==0.9.*->httpx==0.13.3->googletrans) (0.9.0)
Requirement already satisfied: hpack<4,>=3.0 in c:\programdata\anaconda3\envs\python310\lib\site-packages (from h2==3.*->httpcore==0.9.*->httpx==0.13.3->googletrans) (3.0.0)
Requirement already satisfied: hyperframe<6,>=5.2.0 in c:\programdata\anaconda3\envs\python310\lib\site-packages (from h2==3.*->httpcore==0.9.*->httpx==0.13.3->googletrans) (5.2.0)
Installing collected packages: idna, hstspreload, h2, httpcore, httpx, googletrans
  Attempting uninstall: idna
    Found existing installation: idna 3.3
    Uninstalling idna-3.3:
Output exceeds the size limit. Open the full output data in a text editor
WARNING: Ignoring invalid distribution -na (c:\programdata\anaconda3\envs\python310\lib\site-packages)
WARNING: Ignoring invalid distribution -2na (c:\programdata\anaconda3\envs\python310\lib\site-packages)
WARNING: Ignoring invalid distribution -1na (c:\programdata\anaconda3\envs\python310\lib\site-packages)
WARNING: Ignoring invalid distribution -na (c:\programdata\anaconda3\envs\python310\lib\site-packages)
WARNING: Ignoring invalid distribution -0na (c:\programdata\anaconda3\envs\python310\lib\site-packages)
WARNING: Ignoring invalid distribution - (c:\programdata\anaconda3\envs\python310\lib\site-packages)
WARNING: Ignoring invalid distribution -dna (c:\programdata\anaconda3\envs\python310\lib\site-packages)
WARNING: Ignoring invalid distribution -na (c:\programdata\anaconda3\envs\python310\lib\site-packages)
WARNING: Ignoring invalid distribution -2na (c:\programdata\anaconda3\envs\python310\lib\site-packages)
WARNING: Ignoring invalid distribution -1na (c:\programdata\anaconda3\envs\python310\lib\site-packages)
WARNING: Ignoring invalid distribution -na (c:\programdata\anaconda3\envs\python310\lib\site-packages)
WARNING: Ignoring invalid distribution -0na (c:\programdata\anaconda3\envs\python310\lib\site-packages)
WARNING: Ignoring invalid distribution - (c:\programdata\anaconda3\envs\python310\lib\site-packages)
WARNING: Ignoring invalid distribution -dna (c:\programdata\anaconda3\envs\python310\lib\site-packages)
WARNING: Ignoring invalid distribution -na (c:\programdata\anaconda3\envs\python310\lib\site-packages)
WARNING: Ignoring invalid distribution -2na (c:\programdata\anaconda3\envs\python310\lib\site-packages)
WARNING: Ignoring invalid distribution -1na (c:\programdata\anaconda3\envs\python310\lib\site-packages)
WARNING: Ignoring invalid distribution -na (c:\programdata\anaconda3\envs\python310\lib\site-packages)
WARNING: Ignoring invalid distribution -0na (c:\programdata\anaconda3\envs\python310\lib\site-packages)
WARNING: Ignoring invalid distribution - (c:\programdata\anaconda3\envs\python310\lib\site-packages)
WARNING: Ignoring invalid distribution -dna (c:\programdata\anaconda3\envs\python310\lib\site-packages)
    WARNING: Ignoring invalid distribution -na (c:\programdata\anaconda3\envs\python310\lib\site-packages)
    WARNING: Ignoring invalid distribution -2na (c:\programdata\anaconda3\envs\python310\lib\site-packages)
    WARNING: Ignoring invalid distribution -1na (c:\programdata\anaconda3\envs\python310\lib\site-packages)
    WARNING: Ignoring invalid distribution -na (c:\programdata\anaconda3\envs\python310\lib\site-packages)
...
WARNING: Ignoring invalid distribution -na (c:\programdata\anaconda3\envs\python310\lib\site-packages)
WARNING: Ignoring invalid distribution -0na (c:\programdata\anaconda3\envs\python310\lib\site-packages)
WARNING: Ignoring invalid distribution - (c:\programdata\anaconda3\envs\python310\lib\site-packages)
WARNING: Ignoring invalid distribution -dna (c:\programdata\anaconda3\envs\python310\lib\site-packages

它安装了这些警告。

这里怎么了?是安装还是导入语法,以及我如何解决它。

注:我使用的是3.9.7和3.10的anaconda

EN

回答 2

Stack Overflow用户

发布于 2022-03-31 07:41:08

我从你的日志中看到你在使用Anaconda。若要使用conda安装此软件包,请运行以下命令之一:

代码语言:javascript
运行
复制
conda install -c conda-forge googletrans

conda install -c conda-forge/label/cf201901 googletrans

conda install -c conda-forge/label/cf202003 googletrans
票数 0
EN

Stack Overflow用户

发布于 2022-03-31 18:23:27

这段代码是通过anaconda还是通过外部运行的?如果使用外部运行,请使用anaconda打开spyder,然后再试一次。

如果需要外部运行,则必须在pip install googletrans中安装cmd.exe并将python添加到path中。

如何将python添加到路径中?:https://superuser.com/questions/143119/how-do-i-add-python-to-the-windows-path

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/71688576

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档