'youtube_dl ModuleNotFound error on Heroku deployment
I am trying to run my Discord bot on Heroku, but this error keeps popping up when I try to build. I think it has something to do with the module I am trying to download called apafy. I can install it without issues on my own PC, but I'm running into issues on Heroku.
-----> Building on the Heroku-20 stack
-----> Using buildpacks:
1. heroku/python
2. https://github.com/jonathanong/heroku-buildpack-ffmpeg-latest.git
3. https://github.com/xrisk/heroku-opus.git
-----> Python app detected
-----> Using Python version specified in runtime.txt
-----> Python version has changed from python-3.9.10 to python-3.10.2, clearing cache
-----> Requirements file has been changed, clearing cached dependencies
-----> Installing python-3.10.2
-----> Installing pip 21.3.1, setuptools 57.5.0 and wheel 0.37.0
-----> Installing SQLite3
-----> Installing requirements with pip
Collecting discord==1.7.3
Downloading discord-1.7.3-py3-none-any.whl (1.1 kB)
Collecting PyNaCl==1.4.0
Downloading PyNaCl-1.4.0-cp35-abi3-manylinux1_x86_64.whl (961 kB)
Collecting youtube-dl==2021.12.17
Downloading youtube_dl-2021.12.17-py2.py3-none-any.whl (1.9 MB)
Collecting apafy==0.5.6.1
Downloading apafy-0.5.6.1.tar.gz (34 kB)
Preparing metadata (setup.py): started
Preparing metadata (setup.py): finished with status 'error'
ERROR: Command errored out with exit status 1:
command: /app/.heroku/python/bin/python -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-bvs5njap/apafy_8fab839186e14eed8dceb069854e7599/setup.py'"'"'; __file__='"'"'/tmp/pip-install-bvs5njap/apafy_8fab839186e14eed8dceb069854e7599/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /tmp/pip-pip-egg-info-ntv9wsqp
cwd: /tmp/pip-install-bvs5njap/apafy_8fab839186e14eed8dceb069854e7599/
Complete output (16 lines):
Traceback (most recent call last):
File "/tmp/pip-install-bvs5njap/apafy_8fab839186e14eed8dceb069854e7599/apafy/pafy.py", line 48, in <module>
import youtube_dl
ModuleNotFoundError: No module named 'youtube_dl'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/tmp/pip-install-bvs5njap/apafy_8fab839186e14eed8dceb069854e7599/setup.py", line 13, in <module>
from apafy import __version__
File "/tmp/pip-install-bvs5njap/apafy_8fab839186e14eed8dceb069854e7599/apafy/__init__.py", line 7, in <module>
from .pafy import new
File "/tmp/pip-install-bvs5njap/apafy_8fab839186e14eed8dceb069854e7599/apafy/pafy.py", line 51, in <module>
raise ImportError(
ImportError: pafy: youtube-dl not found; you can use the internal backend by setting the environmental variable PAFY_BACKEND to "internal". It is not enabled by default because it is not as well maintained as the youtube-dl backend.
----------------------------------------
WARNING: Discarding https://files.pythonhosted.org/packages/8a/d4/e2a27707c66a57b45b537bf77d0904cf912b4cf74f960fd54b75107207ac/apafy-0.5.6.1.tar.gz#sha256=abef75339d167e13737f0dd5f9f21947bb1a7dfbbdd9359995c10ec7b7f154dd (from https://pypi.org/simple/apafy/). Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
ERROR: Could not find a version that satisfies the requirement apafy==0.5.6.1 (from versions: 0.5.6.1)
ERROR: No matching distribution found for apafy==0.5.6.1
! Push rejected, failed to compile Python app.
! Push failed
Here is my requirements.txt file:
discord == 1.7.3
PyNaCl == 1.4.0
youtube-dl == 2021.12.17
apafy == 0.5.6.1
Solution 1:[1]
You should use youtube_dl (underscore) rather than youtube-dl (dash). When installing via pip, the package is referred to as youtube_dl (see these docs for more details).
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | BrokenBenchmark |
