在Heroku上构建错误

时间:2014-06-05 10:47:38

标签: python heroku

我正在将我的Python应用程序推送到Heroku,它正在安装需求,最后它崩溃了。下面是日志的尾部:

....
SWIG/_m2crypto_wrap.c:4237: warning: 'saltlen' may be used uninitialized in this function
gcc -pthread -shared build/temp.linux-x86_64-2.7/SWIG/_m2crypto_wrap.o -L/usr/lib -lssl -lcrypto -o build/lib.linux-x86_64-2.7/M2Crypto/__m2crypto.so
Creating /tmp/build_5a922389-3865-4fa2-9bc3-ecfa3cd84781/.heroku/venv/lib/python2.7/site-packages/M2Crypto.egg-link (link to .)
M2Crypto 0.22.dev is already the active version in easy-install.pth

Installed /tmp/build_5a922389-3865-4fa2-9bc3-ecfa3cd84781/.heroku/src/m2crypto
Successfully installed M2Crypto
Cleaning up...
Traceback (most recent call last):
  File "/tmp/buildpack_5a922389-3865-4fa2-9bc3-ecfa3cd84781/vendor/virtualenv-1.7/virtualenv.py", line 16, in <module>
import tempfile
  File "/usr/local/lib/python2.7/tempfile.py", line 32, in <module>
import io as _io
  File "/usr/local/lib/python2.7/io.py", line 51, in <module>
import _io
ImportError: /tmp/build_5a922389-3865-4fa2-9bc3-ecfa3cd84781/.heroku/venv/lib/python2.7/lib-dynload/_io.so: undefined symbol: _PyLong_AsInt
 !     Error making virtualenv relocatable


 !     Push rejected, failed to compile Python app

这是我正在使用的requrements.txt:

Flask==0.10.1
SQLAlchemy==0.7.8
Flask-Login==0.2.3
Flask-WTF==0.6
Flask-Gravatar
Flask-OAuth==0.12
Flask-SQLAlchemy
Flask-Mail
python-dateutil
alembic
psycopg2
requests
itsdangerous
markdown
raven
blinker
flask-cache
flask-heroku
pygeoip
flask-babel
beautifulsoup4
python-memcached
-e git+https://github.com/Hypernode/M2Crypto#egg=M2Crypto-0.22.dev
birdy

M2Crypto在清理之前编译。

稍后编辑:

如果我在heroku框上运行pip命令,我会收到一个非常类似的错误:

Traceback (most recent call last):
  File "/app/.heroku/venv/bin/pip", line 10, in <module>
load_entry_point('pip==1.0.2', 'console_scripts', 'pip')()
  File "/app/.heroku/venv/lib/python2.7/site-packages/distribute-0.6.24-py2.7.egg/pkg_resources.py", line 337, in load_entry_point
return get_distribution(dist).load_entry_point(group, name)
  File "/app/.heroku/venv/lib/python2.7/site-packages/distribute-0.6.24-py2.7.egg/pkg_resources.py", line 2279, in load_entry_point
return ep.load()
  File "/app/.heroku/venv/lib/python2.7/site-packages/distribute-0.6.24-py2.7.egg/pkg_resources.py", line 1989, in load
entry = __import__(self.module_name, globals(),globals(), ['__name__'])
  File "/app/.heroku/venv/lib/python2.7/site-packages/pip-1.0.2-py2.7.egg/pip/__init__.py", line 5, in <module>
    import subprocess
  File "/usr/local/lib/python2.7/subprocess.py", line 427, in <module>
    import select
ImportError: /app/.heroku/venv/lib/python2.7/lib-dynload/select.so: undefined symbol: _PyInt_AsInt

1 个答案:

答案 0 :(得分:2)

事实证明,Heroku刚刚将其运行时更新为python-2.7.7 我必须指定一个runtime.txt并清除应用程序的缓存(两次)来修复它。

$ cat python-2.7.7>runtime.txt

然后安装heroku repo插件并清除缓存。由于未知的原因,purge_cace第一次没有工作,不得不使用两次。

$ heroku plugins:install https://github.com/heroku/heroku-repo.git
$ heroku repo:purge_cache -a appname

有关heroku-repo plugin here的更多信息。

this stackoverflow threadthis heroku forum thread中讨论了此问题。