将Flask应用部署到Heroku时出现错误

4

我正在尝试将Flask应用部署到Heroku。当我使用heroku local web本地运行该应用时,它可以正常运行。

但是,当我尝试使用git push heroku master进行部署时,出现了错误。

AttributeError: 'module' object has no attribute 'HTTPSConnection'

我已经验证了我安装了正确的https绑定。

python -c "import hashlib; print dir(hashlib)"
python -c "import httplib; print dir(httplib)"
python -c "import httplib; print dir(httplib.HTTPSConnection)"

错误的完整日志如下:

git push heroku master
Counting objects: 29, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (26/26), done.
Writing objects: 100% (29/29), 5.15 KiB | 0 bytes/s, done.
Total 29 (delta 12), reused 0 (delta 0)
remote: Compressing source files... done.
remote: Building source:
remote: 
remote: -----> Python app detected
remote: ERROR:root:code for hash md5 was not found.
remote: Traceback (most recent call last):
remote:   File "/app/.heroku/python/lib/python2.7/hashlib.py", line 139, in <module>
remote:     globals()[__func_name] = __get_hash(__func_name)
remote:   File "/app/.heroku/python/lib/python2.7/hashlib.py", line 91, in __get_builtin_constructor
remote:     raise ValueError('unsupported hash type ' + name)
remote: ValueError: unsupported hash type md5
remote: ERROR:root:code for hash sha1 was not found.
remote: Traceback (most recent call last):
remote:   File "/app/.heroku/python/lib/python2.7/hashlib.py", line 139, in <module>
remote:     globals()[__func_name] = __get_hash(__func_name)
remote:   File "/app/.heroku/python/lib/python2.7/hashlib.py", line 91, in __get_builtin_constructor
remote:     raise ValueError('unsupported hash type ' + name)
remote: ValueError: unsupported hash type sha1
remote: ERROR:root:code for hash sha224 was not found.
remote: Traceback (most recent call last):
remote:   File "/app/.heroku/python/lib/python2.7/hashlib.py", line 139, in <module>
remote:     globals()[__func_name] = __get_hash(__func_name)
remote:   File "/app/.heroku/python/lib/python2.7/hashlib.py", line 91, in __get_builtin_constructor
remote:     raise ValueError('unsupported hash type ' + name)
remote: ValueError: unsupported hash type sha224
remote: ERROR:root:code for hash sha256 was not found.
remote: Traceback (most recent call last):
remote:   File "/app/.heroku/python/lib/python2.7/hashlib.py", line 139, in <module>
remote:     globals()[__func_name] = __get_hash(__func_name)
remote:   File "/app/.heroku/python/lib/python2.7/hashlib.py", line 91, in __get_builtin_constructor
remote:     raise ValueError('unsupported hash type ' + name)
remote: ValueError: unsupported hash type sha256
remote: ERROR:root:code for hash sha384 was not found.
remote: Traceback (most recent call last):
remote:   File "/app/.heroku/python/lib/python2.7/hashlib.py", line 139, in <module>
remote:     globals()[__func_name] = __get_hash(__func_name)
remote:   File "/app/.heroku/python/lib/python2.7/hashlib.py", line 91, in __get_builtin_constructor
remote:     raise ValueError('unsupported hash type ' + name)
remote: ValueError: unsupported hash type sha384
remote: ERROR:root:code for hash sha512 was not found.
remote: Traceback (most recent call last):
remote:   File "/app/.heroku/python/lib/python2.7/hashlib.py", line 139, in <module>
remote:     globals()[__func_name] = __get_hash(__func_name)
remote:   File "/app/.heroku/python/lib/python2.7/hashlib.py", line 91, in __get_builtin_constructor
remote:     raise ValueError('unsupported hash type ' + name)
remote: ValueError: unsupported hash type sha512
remote: Traceback (most recent call last):
remote:   File "/app/.heroku/python/bin/pip", line 9, in <module>
remote:     load_entry_point('pip==1.3.1', 'console_scripts', 'pip')()
remote:   File "/app/.heroku/python/lib/python2.7/site-packages/distribute-0.6.36-py2.7.egg/pkg_resources.py", line 343, in load_entry_point
remote:     return get_distribution(dist).load_entry_point(group, name)
remote:   File "/app/.heroku/python/lib/python2.7/site-packages/distribute-0.6.36-py2.7.egg/pkg_resources.py", line 2309, in load_entry_point
remote:     return ep.load()
remote:   File "/app/.heroku/python/lib/python2.7/site-packages/distribute-0.6.36-py2.7.egg/pkg_resources.py", line 2015, in load
remote:     entry = __import__(self.module_name, globals(),globals(), ['__name__'])
remote:   File "/app/.heroku/python/lib/python2.7/site-packages/pip-1.3.1-py2.7.egg/pip/__init__.py", line 11, in <module>
remote:     from pip.vcs import git, mercurial, subversion, bazaar  # noqa
remote:   File "/app/.heroku/python/lib/python2.7/site-packages/pip-1.3.1-py2.7.egg/pip/vcs/mercurial.py", line 9, in <module>
remote:     from pip.download import path_to_url2
remote:   File "/app/.heroku/python/lib/python2.7/site-packages/pip-1.3.1-py2.7.egg/pip/download.py", line 72, in <module>
remote:     class VerifiedHTTPSConnection(httplib.HTTPSConnection):
remote: AttributeError: 'module' object has no attribute 'HTTPSConnection'
remote:      $ pip install -r requirements.txt
remote:        ERROR:root:code for hash md5 was not found.
remote:        Traceback (most recent call last):
remote:          File "/app/.heroku/python/lib/python2.7/hashlib.py", line 139, in <module>
remote:            globals()[__func_name] = __get_hash(__func_name)
remote:          File "/app/.heroku/python/lib/python2.7/hashlib.py", line 91, in __get_builtin_constructor
remote:            raise ValueError('unsupported hash type ' + name)
remote:        ValueError: unsupported hash type md5
remote:        ERROR:root:code for hash sha1 was not found.
remote:        Traceback (most recent call last):
remote:          File "/app/.heroku/python/lib/python2.7/hashlib.py", line 139, in <module>
remote:            globals()[__func_name] = __get_hash(__func_name)
remote:          File "/app/.heroku/python/lib/python2.7/hashlib.py", line 91, in __get_builtin_constructor
remote:            raise ValueError('unsupported hash type ' + name)
remote:        ValueError: unsupported hash type sha1
remote:        ERROR:root:code for hash sha224 was not found.
remote:        Traceback (most recent call last):
remote:          File "/app/.heroku/python/lib/python2.7/hashlib.py", line 139, in <module>
remote:            globals()[__func_name] = __get_hash(__func_name)
remote:          File "/app/.heroku/python/lib/python2.7/hashlib.py", line 91, in __get_builtin_constructor
remote:            raise ValueError('unsupported hash type ' + name)
remote:        ValueError: unsupported hash type sha224
remote:        ERROR:root:code for hash sha256 was not found.
remote:        Traceback (most recent call last):
remote:          File "/app/.heroku/python/lib/python2.7/hashlib.py", line 139, in <module>
remote:            globals()[__func_name] = __get_hash(__func_name)
remote:          File "/app/.heroku/python/lib/python2.7/hashlib.py", line 91, in __get_builtin_constructor
remote:            raise ValueError('unsupported hash type ' + name)
remote:        ValueError: unsupported hash type sha256
remote:        ERROR:root:code for hash sha384 was not found.
remote:        Traceback (most recent call last):
remote:          File "/app/.heroku/python/lib/python2.7/hashlib.py", line 139, in <module>
remote:            globals()[__func_name] = __get_hash(__func_name)
remote:          File "/app/.heroku/python/lib/python2.7/hashlib.py", line 91, in __get_builtin_constructor
remote:            raise ValueError('unsupported hash type ' + name)
remote:        ValueError: unsupported hash type sha384
remote:        ERROR:root:code for hash sha512 was not found.
remote:        Traceback (most recent call last):
remote:          File "/app/.heroku/python/lib/python2.7/hashlib.py", line 139, in <module>
remote:            globals()[__func_name] = __get_hash(__func_name)
remote:          File "/app/.heroku/python/lib/python2.7/hashlib.py", line 91, in __get_builtin_constructor
remote:            raise ValueError('unsupported hash type ' + name)
remote:        ValueError: unsupported hash type sha512
remote:        Traceback (most recent call last):
remote:          File "/app/.heroku/python/bin/pip", line 9, in <module>
remote:            load_entry_point('pip==1.3.1', 'console_scripts', 'pip')()
remote:          File "/app/.heroku/python/lib/python2.7/site-packages/distribute-0.6.36-py2.7.egg/pkg_resources.py", line 343, in load_entry_point
remote:            return get_distribution(dist).load_entry_point(group, name)
remote:          File "/app/.heroku/python/lib/python2.7/site-packages/distribute-0.6.36-py2.7.egg/pkg_resources.py", line 2309, in load_entry_point
remote:            return ep.load()
remote:          File "/app/.heroku/python/lib/python2.7/site-packages/distribute-0.6.36-py2.7.egg/pkg_resources.py", line 2015, in load
remote:            entry = __import__(self.module_name, globals(),globals(), ['__name__'])
remote:          File "/app/.heroku/python/lib/python2.7/site-packages/pip-1.3.1-py2.7.egg/pip/__init__.py", line 11, in <module>
remote:            from pip.vcs import git, mercurial, subversion, bazaar  # noqa
remote:          File "/app/.heroku/python/lib/python2.7/site-packages/pip-1.3.1-py2.7.egg/pip/vcs/mercurial.py", line 9, in <module>
remote:            from pip.download import path_to_url2
remote:          File "/app/.heroku/python/lib/python2.7/site-packages/pip-1.3.1-py2.7.egg/pip/download.py", line 72, in <module>
remote:            class VerifiedHTTPSConnection(httplib.HTTPSConnection):
remote:        AttributeError: 'module' object has no attribute 'HTTPSConnection'
remote: 
remote:  !     Push rejected, failed to compile Python app
1个回答

6

这个错误是由heroku生成的。原来我没有使用正确的配置来构建应用程序。不知何故,我错过了包含以下文本的runtime.txt文件。

python-2.7.11

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接