我正在尝试导入一个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:\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
发布于 2022-03-31 07:41:08
我从你的日志中看到你在使用Anaconda。若要使用conda安装此软件包,请运行以下命令之一:
conda install -c conda-forge googletrans
conda install -c conda-forge/label/cf201901 googletrans
conda install -c conda-forge/label/cf202003 googletrans
发布于 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
https://stackoverflow.com/questions/71688576
复制相似问题