youtube_dl ModuleNotFound error on Heroku deployment - python

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

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).

i fix it by install library from my code because pafy needs youtube-dl installed before but heroku install all of them together so you can install apafy from your code
import subprocess, sys
def install(package):
subprocess.check_call([sys.executable, "-m", "pip", "install", package])
try:
import apafy as pafy
except Exception as error:
print("Error: ", error)
install("apafy==0.5.6.1")
import apafy as pafy

Related

Python3.8 signXml future error during pip install

Running pip install -r ./requirements fails for signXMl module. Where pip is there in a VENV.
Python version: 3.8.
OS: MAC OS, python installation using brew.
Error:
Using cached future-0.18.1.tar.gz (828 kB)
ERROR: Command errored out with exit status 1:
command: /Users/rahulroy/Desktop/work/data_new/data/venv/bin/python3.8 -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/c3/vl0yxxj17fvbwkh1msldlhnc0000gn/T/pip-install-4_opjnck/future_29cfb8bb91d24ea5b8bad3f63de44251/setup.py'"'"'; __file__='"'"'/private/var/folders/c3/vl0yxxj17fvbwkh1msldlhnc0000gn/T/pip-install-4_opjnck/future_29cfb8bb91d24ea5b8bad3f63de44251/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 /private/var/folders/c3/vl0yxxj17fvbwkh1msldlhnc0000gn/T/pip-pip-egg-info-lflwd8df
cwd: /private/var/folders/c3/vl0yxxj17fvbwkh1msldlhnc0000gn/T/pip-install-4_opjnck/future_29cfb8bb91d24ea5b8bad3f63de44251/
Complete output (15 lines):
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/Users/rahulroy/Desktop/work/data_new/data-gateway/venv/lib/python3.8/site-packages/setuptools/__init__.py", line 3, in <module>
from fnmatch import fnmatchcase
File "/usr/local/Cellar/python#3.8/3.8.12/Frameworks/Python.framework/Versions/3.8/lib/python3.8/fnmatch.py", line 14, in <module>
import re
File "/usr/local/Cellar/python#3.8/3.8.12/Frameworks/Python.framework/Versions/3.8/lib/python3.8/re.py", line 127, in <module>
import functools
File "/usr/local/Cellar/python#3.8/3.8.12/Frameworks/Python.framework/Versions/3.8/lib/python3.8/functools.py", line 18, in <module>
from collections import namedtuple
File "/usr/local/Cellar/python#3.8/3.8.12/Frameworks/Python.framework/Versions/3.8/lib/python3.8/collections/__init__.py", line 27, in <module>
from reprlib import recursive_repr as _recursive_repr
File "/private/var/folders/c3/vl0yxxj17fvbwkh1msldlhnc0000gn/T/pip-install-4_opjnck/future_29cfb8bb91d24ea5b8bad3f63de44251/src/reprlib/__init__.py", line 7, in <module>
raise ImportError('This package should not be accessible on Python 3. '
ImportError: This package should not be accessible on Python 3. Either you are trying to run from the python-future src folder or your installation of python-future is corrupted.
--------------------------------
Which ultimately fails with this error:
INFO: pip is looking at multiple versions of alembic to determine which version is compatible with other requirements. This could take a while.
ERROR: Cannot install signxml because these package versions have conflicting dependencies.
The conflict is caused by:
eight 1.0.1 depends on future<0.19 and >=0.16
eight 1.0.0 depends on future<0.19 and >=0.16
eight 0.4.2 depends on future<0.17 and >=0.16
To fix this you could try to:
1. loosen the range of package versions you've specified
2. remove package versions to allow pip attempt to solve the dependency conflict
ERROR: ResolutionImpossible: for help visit https://pip.pypa.io/en/latest/user_guide/#fixing-conflicting-dependencies
WARNING: You are using pip version 21.1.1; however, version 21.2.4 is available.
Parts of requirements.txt
s3transfer==0.3.3
signxml==2.8.2
six==1.15.0
soupsieve==2.2.1
SQLAlchemy==1.3.18
toml==0.10.1
urllib3==1.25.10
validators==0.18.2
virtualenv==20.0.30
Werkzeug==1.0.1
xmltodict==0.12.0
yapf==0.30.0
zipfile38==0.0.3
The pip logs before the error:
> Requirement already satisfied: setuptools>=3.0 in
> ./venv/lib/python3.8/site-packages (from gunicorn==20.0.4->-r
> requirements.txt (line 41)) (56.0.0) Collecting macholib>=1.8 Using
> cached macholib-1.15.2-py2.py3-none-any.whl (37 kB) Collecting
> eight<2,>=0.4.2 Using cached eight-1.0.1-py2.py3-none-any.whl (10
> kB) Collecting pyopenssl Using cached
> pyOpenSSL-19.1.0-py2.py3-none-any.whl (53 kB) Collecting
> decorator>=3.4.0 Using cached decorator-5.1.0-py3-none-any.whl (9.1
> kB) Collecting future<0.19,>=0.16 Using cached future-0.18.2.tar.gz
> (829 kB)
How can I resolve this error?

Cannot install python arcade on mac

I was trying to do something with python, so I tried to install arcade. Just pip install arcade didn't work and I've tried other stuff too like following this link. None of it worked, It always gave me the same error. This is the whole log.
Collecting arcade
Using cached arcade-2.5.2-py3-none-any.whl (38.3 MB)
Collecting numpy==1.19.2
Using cached numpy-1.19.2.zip (7.3 MB)
Installing build dependencies: started
Installing build dependencies: finished with status 'done'
Getting requirements to build wheel: started
Getting requirements to build wheel: finished with status 'done'
Preparing wheel metadata: started
Preparing wheel metadata: still running...
Preparing wheel metadata: finished with status 'done'
Collecting pytiled-parser==0.9.4a3
Using cached pytiled_parser-0.9.4a3-py3-none-any.whl (15 kB)
Collecting pillow~=8.0
Using cached Pillow-8.1.0-cp39-cp39-macosx_10_10_x86_64.whl (2.2 MB)
Collecting pyglet<2,>=1.5.11
Using cached pyglet-1.5.14-py3-none-any.whl (1.1 MB)
Collecting pymunk~=5.7
Using cached pymunk-5.7.0-py2.py3-none-macosx_10_13_x86_64.whl (201 kB)
Collecting cffi!=1.13.1
Using cached cffi-1.14.4-cp39-cp39-macosx_10_9_x86_64.whl (177 kB)
Collecting pyyaml~=5.3
Using cached PyYAML-5.4-cp39-cp39-macosx_10_9_x86_64.whl (259 kB)
Collecting shapely~=1.7
Using cached Shapely-1.7.1.tar.gz (383 kB)
ERROR: Command errored out with exit status 1:
command: /Users/AaronKanaron/PycharmProjects/arcadeTest/venv/bin/python -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/vq/283xsscx57v67tffn6yn4_s80000gp/T/pip-install-dncw7kpb/shapely_c0fed3cf0b1b47b7b3c8397e61f3a6f7/setup.py'"'"'; __file__='"'"'/private/var/folders/vq/283xsscx57v67tffn6yn4_s80000gp/T/pip-install-dncw7kpb/shapely_c0fed3cf0b1b47b7b3c8397e61f3a6f7/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /private/var/folders/vq/283xsscx57v67tffn6yn4_s80000gp/T/pip-pip-egg-info-4y1krwzl
cwd: /private/var/folders/vq/283xsscx57v67tffn6yn4_s80000gp/T/pip-install-dncw7kpb/shapely_c0fed3cf0b1b47b7b3c8397e61f3a6f7/
Complete output (12 lines):
Failed `CDLL(/Library/Frameworks/GEOS.framework/Versions/Current/GEOS)`
Failed `CDLL(/opt/local/lib/libgeos_c.dylib)`
Failed `CDLL(/usr/local/lib/libgeos_c.dylib)`
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/private/var/folders/vq/283xsscx57v67tffn6yn4_s80000gp/T/pip-install-dncw7kpb/shapely_c0fed3cf0b1b47b7b3c8397e61f3a6f7/setup.py", line 85, in <module>
from shapely._buildcfg import geos_version_string, geos_version, \
File "/private/var/folders/vq/283xsscx57v67tffn6yn4_s80000gp/T/pip-install-dncw7kpb/shapely_c0fed3cf0b1b47b7b3c8397e61f3a6f7/shapely/_buildcfg.py", line 190, in <module>
lgeos = load_dll('geos_c', fallbacks=alt_paths)
File "/private/var/folders/vq/283xsscx57v67tffn6yn4_s80000gp/T/pip-install-dncw7kpb/shapely_c0fed3cf0b1b47b7b3c8397e61f3a6f7/shapely/_buildcfg.py", line 162, in load_dll
raise OSError(
OSError: Could not find library geos_c or load any of its variants ['/Library/Frameworks/GEOS.framework/Versions/Current/GEOS', '/opt/local/lib/libgeos_c.dylib', '/usr/local/lib/libgeos_c.dylib']
----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
It can't find setup.py, and what I've searched nothing has helped me so far. So if any of you could help me with this problem it would be fantastic.
You have to install the library GEOS on your system. Run this command - brew install geos.
If you don't have brew, you can download it here: https://brew.sh
On ubuntu, you can do $ sudo apt-get install libgeos-dev.

Problems with installing plotly on Windows 10 with Python 3.8.5

I am having problems installing plotly on Windows 10 with Python 3.8.5. The command line prompt is in admin mode.
The package manager pip3 here seems to be installing the package retrying-1.3.3 which is running into an error:
ModuleNotFoundError: No module named '_distutils_hack'
Anybody has a solution for this? Greatly appreciate your time. Thanks
C:\ProgramData\Python38\Scripts>pip3 install plotly
Collecting plotly
Using cached plotly-4.14.1-py2.py3-none-any.whl (13.2 MB)
Requirement already satisfied: six in c:\programdata\python38\lib\site-packages (from plotly) (1.15.0)
Collecting retrying>=1.3.3
Using cached retrying-1.3.3.tar.gz (10 kB)
ERROR: Command errored out with exit status 1:
command: 'c:\programdata\python38\python.exe' -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\student\\AppData\\Local\\Temp\\pip-install-2qndeluw\\retrying_de785ef56b9d4150b577dd9f4437e271\\setup.py'"'"'; __file__='"'"'C:\\Users\\student\\AppData\\Local\\Temp\\pip-install-2qndeluw\\retrying_de785ef56b9d4150b577dd9f4437e271\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base 'C:\Users\student\AppData\Local\Temp\pip-pip-egg-info-3tjoj6d_'
cwd: C:\Users\student\AppData\Local\Temp\pip-install-2qndeluw\retrying_de785ef56b9d4150b577dd9f4437e271\
Complete output (5 lines):
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "c:\programdata\python38\lib\site-packages\setuptools\__init__.py", line 8, in <module>
import _distutils_hack.override # noqa: F401
ModuleNotFoundError: No module named '_distutils_hack'
----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
The problem may be that the version of the 'setuptools' package is too old. I just updated it when I encountered this problem before.
pip install --upgrade setuptools

Orange3 installation with pip3

I have been trying to install orange3 on my Linux machine. Upon trying:
pip3 install orange3
I get this verbos error:
WARNING: pip is being invoked by an old script wrapper. This will fail in a future version of pip.
Please see https://github.com/pypa/pip/issues/5599 for advice on fixing the underlying issue.
To avoid this problem you can invoke Python with '-m pip' instead of running pip directly.
Defaulting to user installation because normal site-packages is not writeable
Collecting orange3
Using cached Orange3-3.27.1-cp36-cp36m-manylinux1_x86_64.whl (2.7 MB)
Collecting AnyQt>=0.0.11
Downloading AnyQt-0.0.11-py2.py3-none-any.whl (46 kB)
Collecting baycomp>=1.0.2
Using cached baycomp-1.0.2-py3-none-any.whl (17 kB)
Requirement already satisfied: pip>=9.0 in ./.local/lib/python3.6/site-packages (from orange3) (20.2.4)
Requirement already satisfied: scikit-learn!=0.23.0,>=0.22.0 in ./.local/lib/python3.6/site-packages (from orange3) (0.22.1)
...
Collecting orange-widget-base>=4.8.1
Using cached orange_widget_base-4.9.0-py3-none-any.whl (229 kB)
...
Collecting python-louvain>=0.13
Using cached python-louvain-0.14.tar.gz (19 kB)
ERROR: Command errored out with exit status 1:
command: /usr/bin/python3 -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-_us67ap2/python-louvain/setup.py'"'"'; __file__='"'"'/tmp/pip-install-_us67ap2/python-louvain/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /tmp/pip-pip-egg-info-t2a936sw
cwd: /tmp/pip-install-_us67ap2/python-louvain/
Complete output (28 lines):
Traceback (most recent call last):
File "/usr/local/lib/python3.6/dist-packages/pkg_resources/__init__.py", line 2455, in resolve
return functools.reduce(getattr, self.attrs, module)
AttributeError: type object 'Distribution' has no attribute '_finalize_feature_opts'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/tmp/pip-install-_us67ap2/python-louvain/setup.py", line 25, in <module>
scripts=['bin/community']
...
raise ImportError(str(exc)) from exc
ImportError: type object 'Distribution' has no attribute '_finalize_feature_opts'
----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
I have already tried updating pip as well as setup-tools using
pip install --upgrade pip
etc but I still get this error.
You probably have a too old version of the setuptools package. Try upgrading it (and pip as well, while you're at it): python3 -m pip install setuptools pip.
Here's a link to a setuptools issue describing the problem: https://github.com/pypa/setuptools/issues/2029

exit status 1 when trying to pip install cantools

Whenever I try to pip install cantools==34.0.0 (on python 2.7)
i receive the error:
DEPRECATION: Python 2.7 reached the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 is no longer maintained. pip 21.0 will drop support for Python 2.7 in January 2021. More details about Python 2 support
in pip can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support
Collecting cantools==34.0.0
Using cached cantools-34.0.0-py2.py3-none-any.whl (77 kB)
Collecting diskcache
Using cached diskcache-5.0.2.tar.gz (47 kB)
ERROR: Command errored out with exit status 1:
command: 'c:\venv\scripts\python.exe' -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'c:\\users\\bla\\appdata\\local\\temp\\pip-install-4or8zd\\diskcache\\setup.py'"'"'; __file__='"'"'c:\\
users\\bla\\appdata\\local\\temp\\pip-install-4or8zd\\diskcache\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"
'"'))' egg_info --egg-base 'c:\users\bla\appdata\local\temp\pip-pip-egg-info-mxhtc0'
cwd: c:\users\bla\appdata\local\temp\pip-install-4or8zd\diskcache\
Complete output (10 lines):
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "c:\users\bla\appdata\local\temp\pip-install-4or8zd\diskcache\setup.py", line 5, in <module>
import diskcache
File "diskcache\__init__.py", line 9, in <module>
from .core import (
File "diskcache\core.py", line 434
raise ValueError('disk must subclass diskcache.Disk') from None
^
SyntaxError: invalid syntax
----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
Can anyone please help me? It seems like it happens when it tries to install the package diskcache
I fixed it, the problem was with installing the diskcache module,
By default it tried to install a python 3 version supported version
when I manually installed it pip install diskcache==4.1.0
and then installed cantools again it worked.

Categories