【发布时间】:2020-02-21 17:23:00
【问题描述】:
我有一个使用 Python 2 在 heroku 上的 Python Scrapy 项目。如果我有一些代码更新,我仍然可以推送到 Heroku。
现在我想将 python 版本更新到 Python 3。
看起来 Heroku 支持 Python 3: https://devcenter.heroku.com/changelog-items/1442
所以我将我的runtime.txt 文件从python-2.7.15 更新为python-3.7.0
而我的requirements.txt 是:
pymongo==3.5.1
Scrapy==1.4.0
scrapyd==1.0.1
scrapy-heroku==0.7.1
cffi==1.6.0
requests==2.5.3
然后输入git push heroku master,这里是终端的信息:
Enumerating objects: 15, done.
Counting objects: 100% (15/15), done.
Delta compression using up to 16 threads
Compressing objects: 100% (8/8), done.
Writing objects: 100% (9/9), 740 bytes | 740.00 KiB/s, done.
Total 9 (delta 6), reused 1 (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.7.6
remote: Learn More: https://devcenter.heroku.com/articles/python-runtimes
remote: -----> Found python-2.7.15, removing
remote: -----> Installing python-3.7.0
remote: -----> Installing pip
remote: -----> Installing SQLite3
remote: Sqlite3 successfully installed.
remote: -----> Installing requirements with pip
remote: Collecting pymongo==3.5.1
remote: Downloading pymongo-3.5.1.tar.gz (1.3 MB)
remote: Collecting Scrapy==1.4.0
remote: Downloading Scrapy-1.4.0-py2.py3-none-any.whl (248 kB)
remote: Collecting scrapyd==1.0.1
remote: Downloading scrapyd-1.0.1.tar.gz (32 kB)
remote: Collecting scrapy-heroku==0.7.1
remote: Downloading scrapy-heroku-0.7.1.tar.gz (5.2 kB)
remote: Collecting cffi==1.6.0
remote: Downloading cffi-1.6.0.tar.gz (397 kB)
remote: Collecting requests==2.5.3
remote: Downloading requests-2.5.3-py2.py3-none-any.whl (468 kB)
remote: Collecting Twisted>=13.1.0
remote: Downloading Twisted-19.10.0-cp37-cp37m-manylinux1_x86_64.whl (3.1 MB)
remote: Collecting cssselect>=0.9
remote: Downloading cssselect-1.1.0-py2.py3-none-any.whl (16 kB)
remote: Collecting parsel>=1.1
remote: Downloading parsel-1.5.2-py2.py3-none-any.whl (12 kB)
remote: Collecting w3lib>=1.17.0
remote: Downloading w3lib-1.21.0-py2.py3-none-any.whl (20 kB)
remote: Collecting pyOpenSSL
remote: Downloading pyOpenSSL-19.1.0-py2.py3-none-any.whl (53 kB)
remote: Collecting service-identity
remote: Downloading service_identity-18.1.0-py2.py3-none-any.whl (11 kB)
remote: Collecting PyDispatcher>=2.0.5
remote: Downloading PyDispatcher-2.0.5.tar.gz (34 kB)
remote: Collecting lxml
remote: Downloading lxml-4.5.0-cp37-cp37m-manylinux1_x86_64.whl (5.7 MB)
remote: Collecting six>=1.5.2
remote: Downloading six-1.14.0-py2.py3-none-any.whl (10 kB)
remote: Collecting queuelib
remote: Downloading queuelib-1.5.0-py2.py3-none-any.whl (13 kB)
remote: Collecting distribute
remote: Downloading distribute-0.7.3.zip (145 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-bb2wfsg5/distribute/setup.py'"'"'; __file__='"'"'/tmp/pip-install-bb2wfsg5/distribute/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-install-bb2wfsg5/distribute/pip-egg-info
remote: cwd: /tmp/pip-install-bb2wfsg5/distribute/
remote: Complete output (15 lines):
remote: Traceback (most recent call last):
remote: File "<string>", line 1, in <module>
remote: File "/tmp/pip-install-bb2wfsg5/distribute/setuptools/__init__.py", line 2, in <module>
remote: from setuptools.extension import Extension, Library
remote: File "/tmp/pip-install-bb2wfsg5/distribute/setuptools/extension.py", line 5, in <module>
remote: from setuptools.dist import _get_unpatched
remote: File "/tmp/pip-install-bb2wfsg5/distribute/setuptools/dist.py", line 7, in <module>
remote: from setuptools.command.install import install
remote: File "/tmp/pip-install-bb2wfsg5/distribute/setuptools/command/__init__.py", line 8, in <module>
remote: from setuptools.command import install_scripts
remote: File "/tmp/pip-install-bb2wfsg5/distribute/setuptools/command/install_scripts.py", line 3, in <module>
remote: from pkg_resources import Distribution, PathMetadata, ensure_directory
remote: File "/tmp/pip-install-bb2wfsg5/distribute/pkg_resources.py", line 1518, in <module>
remote: register_loader_type(importlib_bootstrap.SourceFileLoader, DefaultProvider)
remote: AttributeError: module 'importlib._bootstrap' has no attribute 'SourceFileLoader'
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 myproject.
remote:
To https://git.heroku.com/myproject.git
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/myproject.git'
如果我的项目 python 的版本仍然是 2.7.15,push 可以工作。
我不知道为什么我将它更改为 3.7.0 时会被拒绝,我如何在 Heroku 上将我的项目更新到 Python 3?
当更改requests==2.23.0
输出是:
Enumerating objects: 27, done.
Counting objects: 100% (27/27), done.
Delta compression using up to 16 threads
Compressing objects: 100% (18/18), done.
Writing objects: 100% (19/19), 1.59 KiB | 812.00 KiB/s, done.
Total 19 (delta 14), reused 1 (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.7.6
remote: Learn More: https://devcenter.heroku.com/articles/python-runtimes
remote: -----> Found python-2.7.15, removing
remote: -----> Installing python-3.7.0
remote: -----> Installing pip
remote: -----> Installing SQLite3
remote: Sqlite3 successfully installed.
remote: -----> Installing requirements with pip
remote: Collecting pymongo==3.5.1
remote: Downloading pymongo-3.5.1.tar.gz (1.3 MB)
remote: Collecting Scrapy==1.4.0
remote: Downloading Scrapy-1.4.0-py2.py3-none-any.whl (248 kB)
remote: Collecting scrapyd==1.0.1
remote: Downloading scrapyd-1.0.1.tar.gz (32 kB)
remote: Collecting scrapy-heroku==0.7.1
remote: Downloading scrapy-heroku-0.7.1.tar.gz (5.2 kB)
remote: Collecting cffi==1.6.0
remote: Downloading cffi-1.6.0.tar.gz (397 kB)
remote: Collecting requests==2.23.0
remote: Downloading requests-2.23.0-py2.py3-none-any.whl (58 kB)
remote: Collecting queuelib
remote: Downloading queuelib-1.5.0-py2.py3-none-any.whl (13 kB)
remote: Collecting cssselect>=0.9
remote: Downloading cssselect-1.1.0-py2.py3-none-any.whl (16 kB)
remote: Collecting service-identity
remote: Downloading service_identity-18.1.0-py2.py3-none-any.whl (11 kB)
remote: Collecting w3lib>=1.17.0
remote: Downloading w3lib-1.21.0-py2.py3-none-any.whl (20 kB)
remote: Collecting six>=1.5.2
remote: Downloading six-1.14.0-py2.py3-none-any.whl (10 kB)
remote: Collecting pyOpenSSL
remote: Downloading pyOpenSSL-19.1.0-py2.py3-none-any.whl (53 kB)
remote: Collecting parsel>=1.1
remote: Downloading parsel-1.5.2-py2.py3-none-any.whl (12 kB)
remote: Collecting Twisted>=13.1.0
remote: Downloading Twisted-19.10.0-cp37-cp37m-manylinux1_x86_64.whl (3.1 MB)
remote: Collecting lxml
remote: Downloading lxml-4.5.0-cp37-cp37m-manylinux1_x86_64.whl (5.7 MB)
remote: Collecting PyDispatcher>=2.0.5
remote: Downloading PyDispatcher-2.0.5.tar.gz (34 kB)
remote: Collecting distribute
remote: Downloading distribute-0.7.3.zip (145 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-60s4l_1v/distribute/setup.py'"'"'; __file__='"'"'/tmp/pip-install-60s4l_1v/distribute/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-install-60s4l_1v/distribute/pip-egg-info
remote: cwd: /tmp/pip-install-60s4l_1v/distribute/
remote: Complete output (15 lines):
remote: Traceback (most recent call last):
remote: File "<string>", line 1, in <module>
remote: File "/tmp/pip-install-60s4l_1v/distribute/setuptools/__init__.py", line 2, in <module>
remote: from setuptools.extension import Extension, Library
remote: File "/tmp/pip-install-60s4l_1v/distribute/setuptools/extension.py", line 5, in <module>
remote: from setuptools.dist import _get_unpatched
remote: File "/tmp/pip-install-60s4l_1v/distribute/setuptools/dist.py", line 7, in <module>
remote: from setuptools.command.install import install
remote: File "/tmp/pip-install-60s4l_1v/distribute/setuptools/command/__init__.py", line 8, in <module>
remote: from setuptools.command import install_scripts
remote: File "/tmp/pip-install-60s4l_1v/distribute/setuptools/command/install_scripts.py", line 3, in <module>
remote: from pkg_resources import Distribution, PathMetadata, ensure_directory
remote: File "/tmp/pip-install-60s4l_1v/distribute/pkg_resources.py", line 1518, in <module>
remote: register_loader_type(importlib_bootstrap.SourceFileLoader, DefaultProvider)
remote: AttributeError: module 'importlib._bootstrap' has no attribute 'SourceFileLoader'
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 myproject.
remote:
To https://git.heroku.com/myproject.git
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/myproject.git'
【问题讨论】:
-
...other info是什么?这就是有用的信息所在。 -
是的,你的权利,我已经拍了所有的信息,请看一下。
-
对不起,我尝试
purging your build cache不工作。我尝试使用installing pipdeptree并深入了解其中的情况。我最近会报告的。