【问题标题】:No module named 'utils_nlp' when using MS nlp_recipes in google colab在 google colab 中使用 MS nlp_recipes 时没有名为“utils_nlp”的模块
【发布时间】:2020-11-16 11:50:38
【问题描述】:

我想在我的 google colab 项目中使用 MS 的 nlp_recipes github 存储库中提供的 utils_nlp。但是,我收到“没有名为 'utils_nlp' 的模块”错误。这是我尝试过的:

在来自 nlp_recipes 的 setup 中声明:

也可以直接从 Github 安装,这是在外部项目中使用 utils_nlp 包的最佳方式(同时仍然反映源的更新,因为它作为可编辑的“-e”包安装)。

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

我在 colab 中运行

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

效果很好

从git+https://github.com/microsoft/nlp获取utils_nlp recipes.git@master#egg=utils_nlp 克隆 https://github.com/microsoft/nlp-recipes.git(到修订版主)到 ./src/utils-nlp 运行命令 git clone -q https://github.com/microsoft/nlp-recipes.git /content/src/utils-nlp 安装构建依赖项...完成
获得制造轮子的要求...完成
正在准备车轮元数据...完成
安装收集的包:utils-nlp
为 utils-nlp 运行 setup.py develop 安装成功utils-nlp

当我做!pip list 我得到

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

例如当我想从 utils-nlp 导入时

from utils_nlp.dataset.preprocess import to_lowercase, to_spacy_tokens

我得到一个

没有名为“utils_nlp”的模块

我尝试过使用sys.path.append("/content/src/") 和许多其他附加路径,但这些似乎都不起作用。

有什么想法吗?

【问题讨论】:

    标签: python nlp google-colaboratory recipe


    【解决方案1】:

    在安装后和导入之前重新启动您的运行时。

    重启命令是:

    一个完整的例子是:

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-10-27
      • 2022-01-06
      • 2023-01-19
      • 1970-01-01
      • 2019-12-27
      • 1970-01-01
      • 2021-03-21
      • 2021-11-01
      相关资源
      最近更新 更多