【发布时间】:2020-09-06 06:48:40
【问题描述】:
我在将我的项目部署到 Heroku 时有些沮丧。它依赖于一些用于占星术软件的 python 库,它们在我的本地机器上运行良好。但是其中一个库需要您下载一些文件并设置下载文件的路径才能运行,我认为它在构建过程中此时失败了。该库是对另一个最初用 C 编写的库的 Python 扩展。python 库是 here。我一直在查看一些文档 here 和 here 和 here,但我从未构建过 docker 映像,我什至不确定它是否能解决我的问题。我也想过添加一个新的 buildpack,但也不确定它是否能解决问题。我的错误如下,希望有人能指出我正确的方向。我主要是在找人告诉我我的问题是否可以通过 Docker 或其他方式解决,这样如果没有帮助,我就不会浪费时间沿着这条路走下去。谢谢。
Installing collected packages: pyswisseph
2020-05-20T00:01:48.839661+00:00 app[web.1]: Running setup.py install for pyswisseph: started
2020-05-20T00:01:48.839662+00:00 app[web.1]: Running setup.py install for pyswisseph: finished with status 'error'
2020-05-20T00:01:48.839662+00:00 app[web.1]:
2020-05-20T00:01:48.839801+00:00 app[web.1]: ERROR: Command errored out with exit status 1:
2020-05-20T00:01:48.839814+00:00 app[web.1]: command: /app/.local/share/virtualenvs/app-4PlAip0Q
/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-djfmycyt
/pyswisseph/setup.py'"'"'; __file__='"'"'/tmp/pip-install-djfmycyt/pyswisseph/setup.py'"'"';
f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"',
'"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d /tmp/pip-
wheel-vuz1lu7j
2020-05-20T00:01:48.839815+00:00 app[web.1]: cwd: /tmp/pip-install-djfmycyt/pyswisseph/
2020-05-20T00:01:48.839815+00:00 app[web.1]: Complete output (23 lines):
2020-05-20T00:01:48.839816+00:00 app[web.1]: Searching system libswe...
2020-05-20T00:01:48.839816+00:00 app[web.1]: pkg-config not found
2020-05-20T00:01:48.839816+00:00 app[web.1]: Using internal libswe
2020-05-20T00:01:48.839817+00:00 app[web.1]: /app/.local/share/virtualenvs/app-4PlAip0Q
/lib/python3.7/site-packages/setuptools/dist.py:454: UserWarning: Normalizing '2.08.00-1' to
'2.8.0.post1'
2020-05-20T00:01:48.839817+00:00 app[web.1]: warnings.warn(tmpl.format(**locals()))
2020-05-20T00:01:48.839818+00:00 app[web.1]: running bdist_wheel
2020-05-20T00:01:48.839818+00:00 app[web.1]: running build
2020-05-20T00:01:48.839818+00:00 app[web.1]: running build_ext
2020-05-20T00:01:48.839818+00:00 app[web.1]: building 'swisseph' extension
2020-05-20T00:01:48.839819+00:00 app[web.1]: creating build
2020-05-20T00:01:48.839819+00:00 app[web.1]: creating build/temp.linux-x86_64-3.7
2020-05-20T00:01:48.839819+00:00 app[web.1]: creating build/temp.linux-x86_64-3.7/libswe
2020-05-20T00:01:48.839820+00:00 app[web.1]: creating build/temp.linux-x86_64-3.7/swephelp
2020-05-20T00:01:48.839823+00:00 app[web.1]: gcc -pthread -Wno-unused-result -Wsign-compare
-DNDEBUG -g -fwrapv -O3 -Wall -fPIC -Ilibswe -Iswephelp -I/app/.local/share/virtualenvs
/app-4PlAip0Q/include -I/app/.heroku/python/include/python3.7m -c pyswisseph.c -o
build/temp.linux-x86_64-3.7/pyswisseph.o -std=gnu99
2020-05-20T00:01:48.839824+00:00 app[web.1]: In file included from /usr/lib/gcc/x86_64-linux-
gnu/7/include-fixed/syslimits.h:7:0,
2020-05-20T00:01:48.839824+00:00 app[web.1]: from /usr/lib/gcc/x86_64-linux-gnu/7/include-
fixed/limits.h:34,
2020-05-20T00:01:48.839825+00:00 app[web.1]: from /app/.heroku/python/include/python3.7m/Python.h:11,
2020-05-20T00:01:48.839825+00:00 app[web.1]: from pyswisseph.c:58:
2020-05-20T00:01:48.839828+00:00 app[web.1]: /usr/lib/gcc/x86_64-linux-gnu/7/include-fixed/limits.h:194:15: fatal error: limits.h: No such file or directory
2020-05-20T00:01:48.839829+00:00 app[web.1]: #include_next <limits.h> /* recurse down to the
real one */
2020-05-20T00:01:48.839829+00:00 app[web.1]: ^~~~~~~~~~
2020-05-20T00:01:48.839829+00:00 app[web.1]: compilation terminated.
2020-05-20T00:01:48.839846+00:00 app[web.1]: error: command 'gcc' failed with exit status 1
2020-05-20T00:01:48.839847+00:00 app[web.1]: ----------------------------------------
2020-05-20T00:01:48.839847+00:00 app[web.1]: ERROR: Failed building wheel for pyswisseph
编辑 - 以下是无法参考的示例 setup.py 代码:
# Test for pkg-config
has_pkgconfig = False
if swe_detection:
print('Searching system libswe...')
try:
import subprocess
try:
subprocess.check_output(['pkg-config'], stderr=subprocess.STDOUT)
except AttributeError: # < Python 2.7
# detection without pkg-config (or use popen)
pass
except subprocess.CalledProcessError:
has_pkgconfig = True
print('Found pkg-config')
except OSError:
print('pkg-config not found')
pass
except ImportError: # Python < 2.4
pass
#
# Find libswe-dev
libswe_found = False
if has_pkgconfig:
try:
swe_includes = subprocess.check_output(
['pkg-config', '--cflags', 'libswe-'+swe_version],
stderr=subprocess.STDOUT)
swe_libs = subprocess.check_output(
['pkg-config', '--libs', 'libswe-'+swe_version],
stderr=subprocess.STDOUT)
swe_sources = []
swe_depends = []
swe_defines = [('PYSWE_DEFAULT_EPHE_PATH',
'"/usr/share/libswe/ephe2:/usr/share/libswe/ephe"')]
libswe_found = True
print('pkg-config found libswe-'+swe_version)
except subprocess.CalledProcessError:
pass
#
# Another attempt at finding libswe-dev -- without pkg-config
# (pkg-config may be uninstalled but pc file should be in place)
# (and assuming there is only one version installed...)
if ( swe_detection and not libswe_found
and os.path.isfile( '/usr/lib/pkgconfig/libswe-'+swe_version+'.pc' )):
swe_includes = ['/usr/include']
swe_sources = []
swe_depends = []
swe_libs = ['swe']
swe_defines = [('PYSWE_DEFAULT_EPHE_PATH',
'"/usr/share/libswe/ephe2:/usr/share/libswe/ephe"')]
print('Found system libswe')
【问题讨论】:
-
看起来有些问题。您可能需要一一解决并重新运行。通用的一件事(许多软件包使用)是缺少
pkg-config命令。您需要为此安装软件包。我们需要知道你有什么发行版(例如fedora、ubuntu、debian、gentoo、mint、suse)。一些发行版基于rpm并使用dnf/yum来安装软件包。其他的是 debian-bases,有.deb文件并使用apt-get[或dpkg]。 ubuntu 使用apt-get。然后,找到包含pkg-config的包。 fedora (e.g.) do:dnf install pkgconf-pkg-config但 ubuntu 的名字可能不同 -
之后,
limits.h丢失(也是通用的)。 (例如)对于 Fedora,它位于glibc-headers开发包中。给定二进制包的开发包(例如)xxx有时采用以下形式:xxx-devel用于 fedora,xxx-dev用于 ubuntu。例如安装SDL2图形库,二进制包为SDL2,dev pkg为SDL2-devel[fedora],ubuntu会略有不同。 -
谢谢@CraigEstey。我不确定我有哪个发行版。你知道我怎么知道吗?我正在 macOS (Catalina) 上开发。我从未安装过 pkg-config 或使用过 apt,所以我不确定如何安装它们。我还粘贴了我尝试使用的库中的一些源代码,如果有帮助,它在 setup.py 中失败。
-
听起来我可能需要根据这篇文章在 heroku 上设置配置路径环境变量:stackoverflow.com/questions/22995788/…,但我不确定将其设置为什么。
标签: python c linux docker heroku