简体   繁体   中英

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. However, I'm getting a "No module named 'utils_nlp'" error. This is what I have tried:

In the setup from nlp_recipes is stated that:

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).

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

In colab I run

!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
Getting requirements to build wheel... done
Preparing wheel metadata... done
Installing collected packages: utils-nlp
Running setup.py develop for utils-nlp Successfully installed utils-nlp

When I do !pip list I get

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

When I want to import from utils-nlp, for example

from utils_nlp.dataset.preprocess import to_lowercase, to_spacy_tokens

I get a

No module named 'utils_nlp'

I have tried using sys.path.append("/content/src/") and many other paths to append but none of those seem to work.

Any idea?

Restart your runtime after install and prior to import.

Restart command is: 在此处输入图像描述

A full worked example is: 在此处输入图像描述

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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