ModuleNotFoundError:没有名为"googletrans"的模块,尽管我正确安装了它



我试图导入一个googletrans包,但在尝试导入时遇到了ModuleNotFoundError,尽管我安装了它。

我收到这个错误

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包,该包具有所有可能的语法

!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

我收到这个错误

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命令的输出是

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:programdataanaconda3envspython310libsite-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:programdataanaconda3envspython310libsite-packages (from httpx==0.13.3->googletrans) (1.2.0)
Requirement already satisfied: rfc3986<2,>=1.3 in c:programdataanaconda3envspython310libsite-packages (from httpx==0.13.3->googletrans) (1.5.0)
Requirement already satisfied: chardet==3.* in c:programdataanaconda3envspython310libsite-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:programdataanaconda3envspython310libsite-packages (from httpcore==0.9.*->httpx==0.13.3->googletrans) (0.9.0)
Requirement already satisfied: hpack<4,>=3.0 in c:programdataanaconda3envspython310libsite-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:programdataanaconda3envspython310libsite-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:programdataanaconda3envspython310libsite-packages)
WARNING: Ignoring invalid distribution -2na (c:programdataanaconda3envspython310libsite-packages)
WARNING: Ignoring invalid distribution -1na (c:programdataanaconda3envspython310libsite-packages)
WARNING: Ignoring invalid distribution -na (c:programdataanaconda3envspython310libsite-packages)
WARNING: Ignoring invalid distribution -0na (c:programdataanaconda3envspython310libsite-packages)
WARNING: Ignoring invalid distribution - (c:programdataanaconda3envspython310libsite-packages)
WARNING: Ignoring invalid distribution -dna (c:programdataanaconda3envspython310libsite-packages)
WARNING: Ignoring invalid distribution -na (c:programdataanaconda3envspython310libsite-packages)
WARNING: Ignoring invalid distribution -2na (c:programdataanaconda3envspython310libsite-packages)
WARNING: Ignoring invalid distribution -1na (c:programdataanaconda3envspython310libsite-packages)
WARNING: Ignoring invalid distribution -na (c:programdataanaconda3envspython310libsite-packages)
WARNING: Ignoring invalid distribution -0na (c:programdataanaconda3envspython310libsite-packages)
WARNING: Ignoring invalid distribution - (c:programdataanaconda3envspython310libsite-packages)
WARNING: Ignoring invalid distribution -dna (c:programdataanaconda3envspython310libsite-packages)
WARNING: Ignoring invalid distribution -na (c:programdataanaconda3envspython310libsite-packages)
WARNING: Ignoring invalid distribution -2na (c:programdataanaconda3envspython310libsite-packages)
WARNING: Ignoring invalid distribution -1na (c:programdataanaconda3envspython310libsite-packages)
WARNING: Ignoring invalid distribution -na (c:programdataanaconda3envspython310libsite-packages)
WARNING: Ignoring invalid distribution -0na (c:programdataanaconda3envspython310libsite-packages)
WARNING: Ignoring invalid distribution - (c:programdataanaconda3envspython310libsite-packages)
WARNING: Ignoring invalid distribution -dna (c:programdataanaconda3envspython310libsite-packages)
WARNING: Ignoring invalid distribution -na (c:programdataanaconda3envspython310libsite-packages)
WARNING: Ignoring invalid distribution -2na (c:programdataanaconda3envspython310libsite-packages)
WARNING: Ignoring invalid distribution -1na (c:programdataanaconda3envspython310libsite-packages)
WARNING: Ignoring invalid distribution -na (c:programdataanaconda3envspython310libsite-packages)
...
WARNING: Ignoring invalid distribution -na (c:programdataanaconda3envspython310libsite-packages)
WARNING: Ignoring invalid distribution -0na (c:programdataanaconda3envspython310libsite-packages)
WARNING: Ignoring invalid distribution - (c:programdataanaconda3envspython310libsite-packages)
WARNING: Ignoring invalid distribution -dna (c:programdataanaconda3envspython310libsite-packages

安装时带有这些警告。

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

注意:我使用的是带有3.9.7和3.10 的anaconda

我在您的日志中看到您正在使用Anaconda。要使用conda安装此软件包,请运行以下操作之一:

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

这段代码是通过anaconda还是外部运行的?如果您正在使用外部运行,请打开带有anaconda的spyder,然后重试。

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

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

相关内容

  • 没有找到相关文章

最新更新