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

如何对SVC进行超参数调优?

已关闭。此问题需要更加聚焦。目前不接受回答。 想要改进…

如何在初始训练后向模型添加训练数据?

我想在我的scikit-learn模型已经训练完成后再…

使用Google Cloud Function并行运行带有不同用户参数的相同训练作业

我正在寻找一种方法来并行运行带有不同用户参数的相同训练…

加载Keras模型,TypeError: ‘module’ object is not callable

我已经在StackOverflow上搜索并阅读了文档,…

在计算KNN填补方法中特定列中NaN值的”距离平均值”时

当我从头开始实现KNN填补方法来处理缺失数据时,我遇到…

使用巨大的S3 CSV文件或直接从预处理的关系型或NoSQL数据库获取数据的机器学习训练/测试工作

已关闭。此问题需要更多细节或更清晰的说明。目前不接受回…

发表回复

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