Pipenv无法在远程服务器(Heroku)上安装boto3

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Pipenv无法在远程服务器(Heroku)上安装boto3相关的知识,希望对你有一定的参考价值。

我成功部署了django项目,然后我想使用AWS S3来提供静态文件。因此,我安装了必需的软件包,并且一切都在本地运行。但是现在当我尝试git push heroku master时,它失败并显示以下回溯:

Writing objects: 100% (370/370), 5.85 MiB | 2.92 MiB/s, done.
Total 370 (delta 69), reused 0 (delta 0)
remote: Compressing source files... done.
remote: Building source:
remote: 
remote: -----> Python app detected
remote:  !     Python has released a security update! Please consider upgrading to python-3.6.10
remote:        Learn More: https://devcenter.heroku.com/articles/python-runtimes
remote: cp: cannot create regular file '/app/tmp/cache/.heroku/requirements.txt': No such file or directory
remote: -----> Installing python-3.6.9
remote: -----> Installing pip
remote: -----> Installing dependencies with Pipenv 2018.5.18…
remote:        Installing dependencies from Pipfile.lock (acd4c8)…
remote:        An error occurred while installing boto3==1.12.31! Will try again.
remote:        Installing initially–failed dependencies…
remote:        Collecting boto3==1.12.31 
remote:          Using cached https://files.pythonhosted.org/packages/2a/4f/3facbb42e8d07db1ef9b8cefb28dd1dbfcd52a8e32a0323d57f59b10e147/boto3-1.12.31-py2.py3-none-any.whl
remote:        
remote:        THESE PACKAGES DO NOT MATCH THE HASHES FROM Pipfile.lock!. If you have updated the package versions, please update the hashes. Otherwise, examine the package contents carefully; someone may have tampered with them.
remote:            boto3==1.12.31 from https://files.pythonhosted.org/packages/2a/4f/3facbb42e8d07db1ef9b8cefb28dd1dbfcd52a8e32a0323d57f59b10e147/boto3-1.12.31-py2.py3-none-any.whl#sha256=8bf7e3611d46e8214bf225169ac55de762d9d341514f81ebae885dd601138fcf (from -r /tmp/pipenv-sdy5o9v6-requirements/pipenv-k_8vold6-requirement.txt (line 1)):
remote:                Expected sha256 913fc7bbb9df147ed6fa0bd2b391469652ee8cad3e26ca2355e6ff774d9516fb
remote:                     Got        8bf7e3611d46e8214bf225169ac55de762d9d341514f81ebae885dd601138fcf
remote:        
remote:        You are using pip version 9.0.2, however version 20.0.2 is available.
remote:        You should consider upgrading via the 'pip install --upgrade pip' command.
remote:        
remote:  !     Push rejected, failed to compile Python app.
remote: 
remote:  !     Push failed
remote: Verifying deploy...
remote: 
remote: !       Push rejected to shielded-coast-69749.
remote: 
To https://git.heroku.com/shielded-coast-69749.git
 ! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/shielded-coast-69749.git'

[以前,我尝试在本地安装psycopg2时遇到类似的问题,但是经过多次尝试后,除了解决方法(安装psycopg2-binary)外,别无选择。所以在这里我也感到有些绝望。我尝试了pipenv syncpipenv update,最终我重新启动了新的venv,但没有帮助。如果我尝试通过heroku的bash安装boto3,它会起作用。但是由于文件已锁定,因此无法解决问题。

答案

django-storages依赖于1.4.4及更高版本的boto3版本,但pipenv安装了3月28日发布的1.12.31。因此heroku和pypi.org之间可能存在缓存不匹配。因此,您可以通过使用以下命令手动安装boto3来降级boto3

pipenv install "boto=1.4.4"

我已指定1.4.4,因为它是django-storages所需的最低版本。但是您可以安装1.4.4以上的任何版本。

以上是关于Pipenv无法在远程服务器(Heroku)上安装boto3的主要内容,如果未能解决你的问题,请参考以下文章

pipenv快速入门

XML::LibXSLT 无法在 Heroku 上安装

Heroku 权限被拒绝。致命:无法从远程存储库中读取。

安装 pipenv 导致 pip3 无法使用

pipenv 无法安装软件包

如何从 Heroku 访问远程 MySQL 数据库?