Pu sh проект Heroku был отклонен, если я изменю Python версию - PullRequest
1 голос
/ 20 февраля 2020

У меня есть проект Python Scrapy на heroku с использованием Python 2. Я все еще могу добавить sh в 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 pu sh будет работать.

Я не знаю, почему я получаю отклонение при изменении на 3.7.0, как мне обновить мой проект до * 1040? * 3 на Heroku?

При изменении 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'

1 Ответ

2 голосов
/ 21 февраля 2020

Вы (косвенно) зависите от distribute, который является

устаревшим пакетом [предоставляющим] простой уровень совместимости, который устанавливает Setuptools 0.7 +

Он не строится должным образом из-за

AttributeError: module 'importlib._bootstrap' has no attribute 'SourceFileLoader'

, что имеет смысл, поскольку importlib._bootstrap не содержит SourceFileLoader класс в Python 3.7.

* 1016 Страница PyPI *distribute сообщает, что она совместима с Python 2.4, 2.5, 2.6, 2.7, 3.1, 3.2 и 3.3.

Она загружается старой версией requests. Обновите requirements.txt, чтобы использовать более новую версию: последняя версия в настоящее время - 2.23.0 .

Всегда полезно попробовать установить в чистой локальной виртуальной среде с вашего requirements.txt чтобы убедиться, что у вас есть хорошая конфигурация после крупного обновления, и переход от Python 2.7 к Python 3.7 определенно считается серьезным обновлением.

Как только вы будете уверены в содержании вашего requirements.txt, зафиксируйте и повторно разверните.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...