Error Pushing To Heroku with 2captcha library - ModuleNotFoundError: No module named 'requests'

#1
I'm getting this error - ModuleNotFoundError: No module named 'requests' when I run git push heroku master. It's saying I don't have the requests in my requirements.txt but it's clearly in there. I believe something weird is happening because of 2captcha-python. Any ideas on how I can resolve this error? Included my requirements.txt file and error log below.

Requirements.txt file:
Code:
requests==2.25.1

2captcha-python==1.1.0

beautifulsoup4==4.9.3

bs4==0.0.1

cachetools==4.2.2

certifi==2021.5.30

chardet==4.0.0

df2gspread==1.0.4

google-api-python-client==1.6.7

google-auth==1.31.0

google-auth-oauthlib==0.4.4

gspread==3.7.0

httplib2==0.19.1

idna==2.10

lxml==4.6.3

numpy==1.20.3

oauth2client==4.1.3

oauthlib==3.1.1

pandas==1.2.4

pyasn1==0.4.8

pyasn1-modules==0.2.8

pyparsing==2.4.7

python-dateutil==2.8.1

pytz==2021.1

requests-oauthlib==1.3.0

rsa==4.7.2

selenium==3.141.0

six==1.16.0

soupsieve==2.2.1

uritemplate==3.0.1

urllib3==1.26.5

Error log:
Code:
remote: Compressing source files... done.
remote: Building source:
remote:
remote: -----> Building on the Heroku-20 stack
remote: -----> Using buildpacks:
remote:        1. heroku/python
remote:        2. https://github.com/heroku/heroku-buildpack-google-chrome
remote:        3. https://github.com/heroku/heroku-buildpack-chromedriver
remote: -----> Python app detected
remote: -----> No Python version was specified. Using the buildpack default: python-3.9.5
remote:        To use a different version, see: https://devcenter.heroku.com/articles/python-runtimes
remote: -----> Installing python-3.9.5
remote: -----> Installing pip 20.2.4, setuptools 47.1.1 and wheel 0.36.2
remote: -----> Installing SQLite3
remote: -----> Installing requirements with pip
remote:        Collecting requests==2.25.1
remote:          Downloading requests-2.25.1-py2.py3-none-any.whl (61 kB)
remote:        Collecting 2captcha-python==1.1.0
remote:          Downloading 2captcha-python-1.1.0.tar.gz (8.8 kB)
remote:            ERROR: Command errored out with exit status 1:
remote:             command: /app/.heroku/python/bin/python -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-qcbdr2fk/2captcha-python/setup.py'"'"'; __file__='"'"'/tmp/pip-install-qcbdr2fk/2captcha-python/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-y8s7an11
remote:                 cwd: /tmp/pip-install-qcbdr2fk/2captcha-python/
remote:            Complete output (9 lines):
remote:            Traceback (most recent call last):
remote:              File "<string>", line 1, in <module>
remote:              File "/tmp/pip-install-qcbdr2fk/2captcha-python/setup.py", line 4, in <module>
remote:                from twocaptcha import __version__
remote:              File "/tmp/pip-install-qcbdr2fk/2captcha-python/twocaptcha/__init__.py", line 1, in <module>
remote:                from .api import ApiClient
remote:              File "/tmp/pip-install-qcbdr2fk/2captcha-python/twocaptcha/api.py", line 3, in <module>
remote:                import requests
remote:            ModuleNotFoundError: No module named 'requests'
remote:            ----------------------------------------
remote:        ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
remote:  !     Push rejected, failed to compile Python app.
remote:
remote:  !     Push failed
remote: Verifying deploy...
remote:
remote: !       Push rejected to python-selenium-southcarolina.
remote:
To https://git.heroku.com/python-selenium-southcarolina.git
 ! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/python-selenium-southcarolina.git'
 

Jonth

New member
#2
pip first downloads all modules and later install them. So when pip downloads 2captcha then requests is already downloaded but not installed. And this makes problem.

You have to first install all modules except 2captcha and later install only 2captcha. OR first install only requests and later other modules.