Heroku/Django 安装 pylibmc 时错误

4 投票
1 回答
712 浏览
提问于 2025-04-17 14:42

我在尝试把项目部署到Heroku的时候,遇到了一堆错误,真是让人头疼。我按照他们的入门指南操作,但显然这些指南不够全面,还不太准确。

我的设置是一个模块,而我的依赖项是一个文件夹,里面有不同环境的多个.txt文件:

settings/
  base.py
  dev.py
  heroku.py

requirements/
  base.txt
  dev.txt
  heroku.txt

我在base.txt和heroku.txt(heroku.txt是基于base.txt的)里都尝试添加了pylibmc==1.2.2 django-pylibmc-sasl==0.2.4,结果还是没能解决问题。

这里是一些错误信息的简短示例:

_pylibmcmodule.c:2097: warning: passing argument 1 of ‘PyInt_FromLong’ makes integer from pointer without a cast

       /app/.heroku/python/include/python2.7/intobject.h:38: note: expected ‘long int’ but argument is of type ‘struct PylibMC_Behavior *’

       _pylibmcmodule.c:2097: warning: passing argument 1 of ‘PyObject_SetAttrString’ from incompatible pointer type

       /app/.heroku/python/include/python2.7/object.h:472: note: expected ‘struct PyObject *’ but argument is of type ‘struct PylibMC_Behavior *’

       _pylibmcmodule.c:2098: error: ‘PylibMC_McErr’ has no member named ‘name’

       _pylibmcmodule.c:2098: error: ‘PylibMC_McErr’ has no member named ‘exc’

       _pylibmcmodule.c:2098: warning: passing argument 2 of ‘PyModule_AddObject’ from incompatible pointer type

       /app/.heroku/python/include/python2.7/modsupport.h:40: note: expected ‘const char *’ but argument is of type ‘struct PylibMC_Behavior *’

       _pylibmcmodule.c:2100: error: ‘PylibMC_McErr’ has no member named ‘name’

       _pylibmcmodule.c:2100: error: ‘PylibMC_McErr’ has no member named ‘exc’

       _pylibmcmodule.c: In function ‘init_pylibmc’:

       _pylibmcmodule.c:2176: error: ‘LIBMEMCACHED_VERSION_STRING’ undeclared (first use in this function)

       _pylibmcmodule.c:2176: warning: passing argument 3 of ‘PyModule_AddStringConstant’ from incompatible pointer type

       /app/.heroku/python/include/python2.7/modsupport.h:42: note: expected ‘const char *’ but argument is of type ‘struct PylibMC_Behavior *’

       error: command 'gcc' failed with exit status 1

       ----------------------------------------
       Command /app/.heroku/python/bin/python -c "import setuptools;__file__='/app/build/pylibmc/setup.py';exec(compile(open(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --single-version-externally-managed --record /tmp/pip-i0GDaz-record/install-record.txt failed with error code 1 in /app/build/pylibmc
       Storing complete log in /app/.pip/pip.log
 !     Heroku push rejected, failed to compile Python app

我找到了一篇相关的帖子,在这里,这让我想到要把这些库添加到base.txt里,但还是没有帮助。

1 个回答

2

Pylibmc这个库如果在你的requirements.txt文件里,就会自动被支持。

有那么多的需求文件其实是多余的。可以看看十二因素的开发/生产一致性这篇文章。

撰写回答