[英]How to install / import a Python package from a specific package?
I run a code in Google Colab and get the initial error我在 Google Colab 中运行代码并得到初始错误
/usr/local/lib/python3.7/dist-packages/utils_nlp/eval/rouge/rouge_ext.py in <module>()
23 import collections
24
---> 25 from indicnlp.tokenize import sentence_tokenize, indic_tokenize
26 from ...language_utils.hi.hindi_stemmer import hi_stem
27 from rouge import Rouge
ModuleNotFoundError: No module named 'indicnlp.tokenize'
How to install (for instance) the tokenize
package from indicnlp
?如何从 indicnlp 安装(例如)
tokenize
indicnlp
?
I tried我试过了
!pip install indicnlp.tokenize
which apprently doesn't crack it.这显然不会破解它。 How to specify from which package to pip install from?
如何指定从哪个 package 到 pip 安装?
I also tried我也试过
!pip install indicnlp
from indicnlp import tokenize
which doesn't do it either.这也不行。 I then get the error
然后我得到错误
---> 30 from indicnlp import tokenize
31 from utils_nlp import eval
32 from utils_nlp.eval import rouge
ImportError: cannot import name 'tokenize' from 'indicnlp' (/usr/local/lib/python3.7/dist-packages/indicnlp/__init__.py)
Of course if I just do当然,如果我这样做
!pip install tokenize
it does't know which tokenize to install它不知道要安装哪个标记化
It looks like you just pip installed the wrong library.看起来你只是 pip 安装了错误的库。 On pypi I found another project called
indic_nlp_library
( github repo ) that seems to have the packages you're looking for.在 pypi 上,我发现了另一个名为
indic_nlp_library
( github repo ) 的项目,它似乎包含您正在寻找的软件包。 I can get我可以得到
!pip install indic_nlp_library
from indicnlp.tokenize import sentence_tokenize, indic_tokenize
to work.去工作。
Looks like the indicnlp
name was taken on pip by another project.看起来
indicnlp
名称是由另一个项目在 pip 上使用的。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.