简体   繁体   English

在 google colab 中使用 MS nlp_recipes 时没有名为“utils_nlp”的模块

[英]No module named 'utils_nlp' when using MS nlp_recipes in google colab

I want to use the utils_nlp provided in the nlp_recipes github repo from MS in my google colab project.我想在我的 google colab 项目中使用来自 MS 的nlp_recipes github repo 中提供的 utils_nlp。 However, I'm getting a "No module named 'utils_nlp'" error.但是,我收到“没有名为 'utils_nlp' 的模块”错误。 This is what I have tried:这是我尝试过的:

In the setup from nlp_recipes is stated that:在 nlp_recipes 的 设置中指出:

It is also possible to install directly from Github, which is the best way to utilize the utils_nlp package in external projects (while still reflecting updates to the source as it's installed as an editable '-e' package).也可以直接从 Github 安装,这是在外部项目中利用 utils_nlp package 的最佳方式(同时仍然反映源的更新,因为它作为可编辑的“-e”包安装)。

pip install -e git+git@github.com:microsoft/nlp-recipes.git@master#egg=utils_nlp pip install -e git+git@github.com:microsoft/nlp-recipes.git@master#egg=utils_nlp

In colab I run在 colab 我跑

!pip install -e git+https://github.com/microsoft/nlp-recipes.git@master#egg=utils_nlp

Which works perfectly哪个完美

Obtaining utils_nlp from git+https://github.com/microsoft/nlp recipes.git@master#egg=utils_nlp Cloning https://github.com/microsoft/nlp-recipes.git (to revision master) to./src/utils-nlp Running command git clone -q https://github.com/microsoft/nlp-recipes.git /content/src/utils-nlp Installing build dependencies... done从 git+https://github.com/microsoft/nlp recipes.git@master#egg=utils_nlp 获取 utils_nlp 克隆https://github.com/microsoft/nlp-recipes.git (to revision master) to. /utils-nlp 运行命令 git clone -q https://github.com/microsoft/nlp-recipes.git /content/src/utils 安装依赖项...
Getting requirements to build wheel... done获得制造轮子的要求......完成
Preparing wheel metadata... done正在准备车轮元数据...完成
Installing collected packages: utils-nlp安装收集的包:utils-nlp
Running setup.py develop for utils-nlp Successfully installed utils-nlp运行 setup.py develop for utils-nlp 成功安装 utils-nlp

When I do !pip list I get当我做!pip list我得到

utils-nlp 2.0.0 /content/src/utils-nlp utils-nlp 2.0.0 /content/src/utils-nlp

When I want to import from utils-nlp, for example例如,当我想从 utils-nlp 导入时

from utils_nlp.dataset.preprocess import to_lowercase, to_spacy_tokens

I get a我得到一个

No module named 'utils_nlp'没有名为“utils_nlp”的模块

I have tried using sys.path.append("/content/src/") and many other paths to append but none of those seem to work.我尝试使用sys.path.append("/content/src/")和许多其他路径到 append 但这些似乎都不起作用。

Any idea?任何想法?

Restart your runtime after install and prior to import.在安装后和导入之前重新启动运行时。

Restart command is:重启命令为: 在此处输入图像描述

A full worked example is:一个完整的例子是: 在此处输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM