ModuleNotFoundError: 未找到名为’pegasus’的模块

我想尝试使用PEGASUS来总结文章。 https://github.com/google-research/pegasus

原始仓库的README建议使用Google Cloud Compute Engine,但我使用的是Colaboratory笔记本。我是一名在日本的英语教师,我希望我的学生能轻松尝试这款软件。他们可以同时体验机器学习和英语段落摘要的过程。

我按照这个说明进行操作。 https://github.com/google-research/pegasus/tree/f76b63c2886748f7f5c6c9fb547456d8c6002562#setup

这是我的Colab笔记本。https://colab.research.google.com/drive/1p95tZcjhfuCLYh23X3S_gZqRoWVhpIlE?usp=sharing

这是我在笔记本中的代码。

%tensorflow_version 1.x!git clone https://github.com/google-research/pegasus!export PYTHONPATH=/content/pegasus%pip install -r /content/pegasus/requirements.txt!mkdir /content/pegasus/ckpt!gsutil cp -r gs://pegasus_ckpt/ /content/pegasus/ckpt/!python /content/pegasus/pegasus/bin/train.py --params=aeslc_transformer \--param_overrides=vocab_filename=ckpt/pegasus_ckpt/c4.unigram.newline.10pct.96000.model \--train_init_checkpoint=ckpt/pegasus_ckpt/model.ckpt-1500000 \--model_dir=ckpt/pegasus_ckpt/aeslc

然后,我得到了这个错误消息。

Traceback (most recent call last):  File "/content/pegasus/pegasus/bin/train.py", line 17, in <module>    from pegasus.data import infeedModuleNotFoundError: No module named 'pegasus'

这个错误消息表明Python无法导入’pegasus’模块,但我已经通过命令!export PYTHONPATH=/content/pegasus设置了Python路径。

您能给我一些建议吗?


回答:

你不能使用这个

!export PYTHONPATH=/content/pegasus

请改用这个

import osos.environ['PYTHONPATH'] += ':/content/pegasus'

这里有一个示例笔记本,它可以正确运行。

我不使用/content/pegasus/pegasus,我直接使用/content/pegasus,通过!npx degit ..进行安装。

Related Posts

使用LSTM在Python中预测未来值

这段代码可以预测指定股票的当前日期之前的值,但不能预测…

如何在gensim的word2vec模型中查找双词组的相似性

我有一个word2vec模型,假设我使用的是googl…

dask_xgboost.predict 可以工作但无法显示 – 数据必须是一维的

我试图使用 XGBoost 创建模型。 看起来我成功地…

ML Tuning – Cross Validation in Spark

我在https://spark.apache.org/…

如何在React JS中使用fetch从REST API获取预测

我正在开发一个应用程序,其中Flask REST AP…

如何分析ML.NET中多类分类预测得分数组?

我在ML.NET中创建了一个多类分类项目。该项目可以对…

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注