簡體   English   中英

使用 2captcha 庫推送到 Heroku 時出錯 - ModuleNotFoundError:沒有名為“請求”的模塊

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

我收到此錯誤 - ModuleNotFoundError: 當我運行 git push heroku master 時,沒有名為“請求”的模塊。 它是說我的 requirements.txt 中沒有請求,但它顯然在那里。 我相信由於 2captcha-python 正在發生一些奇怪的事情。 關於如何解決此錯誤的任何想法? 包括我的 requirements.txt 文件和下面的錯誤日志。

需求.txt文件:

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

錯誤日志:

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'

pip首先下載所有模塊,然后安裝它們。 因此,當pip下載2captcha requests已下載但未安裝。 這會產生問題。

您必須首先安裝除2captcha之外的所有模塊,然后再安裝2captcha 或者首先只安裝requests然后再安裝其他模塊。


編輯:

我無法對其進行測試,但在文檔中您可以看到它也可以使用setup.py來安裝模塊。 但我不知道它是否會同時運行setup.pyrequirements或僅運行其中之一。

venv本地計算機上,我使用setup.py安裝了兩者

from setuptools import setup

setup(
    install_requires=['requests', 'wheel'],
)

import subprocess

subprocess.run('python -m pip install 2captcha-python', shell=True)

並運行python setup.py install (但Heroku應該自動運行它)


稍后我會在刷新我的帳戶時在Heroku對其進行測試。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM