【问题标题】:deploying python flask app on heroku gives error with functools32在heroku上部署python烧瓶应用程序会导致functools32出错
【发布时间】:2017-12-23 10:08:52
【问题描述】:

关于stackoverflow的第一个问题:D(因为到目前为止我几乎找到了所有东西)。

我尝试将我的 python 应用部署到 Heroku,但出现以下错误:

git push heroku master
Counting objects: 7036, done.
Compressing objects: 100% (3933/3933), done.
Writing objects: 100% (7036/7036), 10.97 MiB | 338.00 KiB/s, done.
Total 7036 (delta 2020), reused 7021 (delta 2014)
remote: Compressing source files... done.
remote: Building source:
remote: 
remote: -----> Python app detected
remote: -----> Installing python-3.6.2
remote: -----> Installing pip
remote: -----> Installing requirements with pip
remote:        Collecting aniso8601==1.2.1 (from -r /tmp/build_3d7108e037a9a8803be5100bdc092768/requirements.txt (line 1))
remote:          Downloading aniso8601-1.2.1.tar.gz (62kB)
remote:        Collecting click==6.7 (from -r /tmp/build_3d7108e037a9a8803be5100bdc092768/requirements.txt (line 2))
remote:          Downloading click-6.7-py2.py3-none-any.whl (71kB)
remote:        Collecting cycler==0.10.0 (from -r /tmp/build_3d7108e037a9a8803be5100bdc092768/requirements.txt (line 3))
remote:          Downloading cycler-0.10.0-py2.py3-none-any.whl
remote:        Collecting deap==1.0.2.post2 (from -r 
remote:        Collecting Flask==0.12.2 (from -r /tmp/build_3d7108e037a9a8803be5100bdc092768/requirements.txt (line 5))
remote:          Downloading Flask-0.12.2-py2.py3-none-any.whl (83kB)
remote:        Collecting Flask-RESTful==0.3.6 (from -r /tmp/build_3d7108e037a9a8803be5100bdc092768/requirements.txt (line 6))
remote:          Downloading Flask_RESTful-0.3.6-py2.py3-none-any.whl
remote:        Collecting functools32==3.2.3.post2 (from -r /tmp/build_3d7108e037a9a8803be5100bdc092768/requirements.txt (line 7))
remote:          Downloading functools32-3.2.3-2.zip
remote:            Complete output from command python setup.py egg_info:
remote:            This backport is for Python 2.7 only.
remote:            
remote:            ----------------------------------------
remote:        Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-l0v0636d/functools32/
remote:  !     Push rejected, failed to compile Python app.
remote: 
remote:  !     Push failed
remote: Verifying deploy...
remote: 
remote: !   Push rejected to XXXXXXX (servername by Heroku).
remote: 

如果我这样做,在我的虚拟盒子上一切正常

pip install -r requirements.txt

我尝试了以下但无济于事:

  • 更改 functools32 版本
  • 从需求文本中删除 functools,这让我意识到这是 Flask 对装饰器的依赖:(

【问题讨论】:

  • 上面的回溯说This backport is for Python 2.7 only.但是你使用的python3已经内置了functools模块。AFAIKfunctools不是烧瓶依赖,但也许你已经使用了2.7在您的烧瓶应用程序中进行反向移植,因为这可能是问题!

标签: python heroku flask functools


【解决方案1】:

答案(感谢 cmets): 我没有意识到我在我的 virtualenv 中使用了 python 2.7(同样,我是初学者)。似乎在某处使用 functools 会自动安装 functools32 包,该包将 functools 从 python 3 移植到 2。Heroku 默认使用 python 3,这就是为什么 functools32 可能不可用的原因。

感谢this post,我现在安装了一个 python 3 虚拟环境,将我喜欢的一些东西从 2 移植到 3,一切都像一个魅力。

感谢 davidism & dimmg 为我指明了正确的方向。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2020-11-08
    • 1970-01-01
    • 2020-08-30
    • 2018-09-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多