【问题标题】:How to install discord.py-rewrite dependency on Heroku for Discord bot hosting?如何在 Heroku 上安装 discord.py-rewrite 依赖项以进行 Discord 机器人托管?
【发布时间】:2019-10-30 12:05:28
【问题描述】:

我正在尝试使用我的 GitHub 主分支在 Heroku 上部署我的 discord.py 机器人,但由于 git 错误:Could not find a tag or branch 'rewrite', assuming commit 而无法执行此操作。我需要做什么才能成功安装“重写”依赖项?

我目前正在使用文件“requirements.txt”、“runtime.txt”、“Procfile”和“Aptfile”。我在 requirements.txt 文件中尝试了几种依赖项组合,包括:

这些是 Heroku 所需文件的内容:

requirements.txt:git+https://github.com/Rapptz/discord.py@rewrite

runtime.txt:python-3.6.8

过程文件:worker: python bot.py

Aptfile:git

当使用任何 git+https://github.com/Rapptz/discord.py@rewrite 尝试部署机器人时,heroku logs --tail 将显示错误:

self.custom_red = discord.Colour.from_rgb(255, 0, 0)  # ff0000
AttributeError: type object 'Colour' has no attribute 'from_rgb' 

我要强调的重要一点是 PyCharm 不会在本地抛出这个错误,即使已经测试了那部分代码。这就是我得出的结论,即我在安装对 Heroku 的“重写”依赖项时遇到问题。

这是 Heroku 上的完整错误日志:

-----> Uninstalling stale dependencies
       Uninstalling discord.py-0.16.12:
         Successfully uninstalled discord.py-0.16.12
-----> Installing requirements with pip
       Collecting git+https://github.com/Rapptz/discord.py@rewrite (from -r /tmp/build_9642c6bfbfd8e0f0ea526230740f0bd1/requirements.txt (line 1))
         Cloning https://github.com/Rapptz/discord.py (to rewrite) to /tmp/pip-41cdp1qz-build
         Could not find a tag or branch 'rewrite', assuming commit.
       error: pathspec 'rewrite' did not match any file(s) known to git.
       Command "git checkout -q rewrite" failed with error code 1 in /tmp/pip-41cdp1qz-build
 !     Push rejected, failed to compile Python app.
 !     Push failed 

话虽如此,是否有任何建议可以帮助我通过成功安装“重写”依赖项来克服此错误,从而使我的机器人在 Heroku 上正常运行?

如果我可以提供任何其他信息,请告诉我。非常感谢任何帮助。

【问题讨论】:

    标签: python heroku discord.py discord.py-rewrite


    【解决方案1】:

    重写分支已合并,不再存在。使用 PyPI 提供的 版本,这是当前最新的。

    【讨论】:

    • 没有用。 Heroku 部署了它,但我仍然收到上面显示的相同 AttributeError。编辑:如果我理解您所说的“使用”是什么意思,我做到了:py -3 -m pip install -U discord.py,然后简单地将 requirements.txt 与discord.py 一起留下。在本地使用 PyCharm 进行测试和工作。然后我提交、推送、部署分支,并因该错误而崩溃。
    • 没关系,现在开始工作了。刚刚得知我必须在 requirements.txt 中指定discord.py==1.2.2,而不仅仅是discord.py。谢谢你的回答。
    【解决方案2】:

    试试这个 把它放到你的requirement.txt中

    discord-ext-alternatives
    discord
    

    它应该准备好了

    【讨论】:

      猜你喜欢
      • 2019-02-14
      • 1970-01-01
      • 2021-05-28
      • 2019-09-23
      • 1970-01-01
      • 2017-06-10
      • 2020-06-27
      • 1970-01-01
      • 2020-08-22
      相关资源
      最近更新 更多