我想在Heroku上部署python / django应用程序。在当地环境中一切正常。我使用pip来安装包。我的requirements.txt如下:
Django==1.6.2
Pillow==2.4.0
dj-database-url==0.3.0
dj-static==0.0.5
django-ckeditor-updated==4.2.8
django-toolbelt==0.0.1
gunicorn==18.0
html5lib==1.0b3
mongoengine==0.8.7
psycopg2==2.5.2
pyPdf==1.13
pymongo==2.7
pystache==0.5.3
reportlab==3.1.8
six==1.6.1
static==1.0.2
wsgiref==0.1.2
xhtml2pdf==0.0.5
但是当使用命令“git push heroku master”在Heroku上部署时,我收到“ReportLab”安装错误:
gcc -pthread -shared build/temp.linux-x86_64-2.7/tmp/pip_build_u4591/reportlab/src/rl_addons/renderPM/_renderPM.o build/temp.linux-x86_64-2.7/tmp/pip_build_u4591/reportlab/src/rl_addons/renderPM/gt1/gt1-parset1.o build/temp.linux-x86_64-2.7/tmp/pip_build_u4591/reportlab/src/rl_addons/renderPM/gt1/gt1-dict.o build/temp.linux-x86_64-2.7/tmp/pip_build_u4591/reportlab/src/rl_addons/renderPM/gt1/gt1-namecontext.o build/temp.linux-x86_64-2.7/tmp/pip_build_u4591/reportlab/src/rl_addons/renderPM/gt1/gt1-region.o build/temp.linux-x86_64-2.7/tmp/pip_build_u4591/reportlab/src/rl_addons/renderPM/libart_lgpl/art_vpath_bpath.o build/temp.linux-x86_64-2.7/tmp/pip_build_u4591/reportlab/src/rl_addons/renderPM/libart_lgpl/art_rgb_pixbuf_affine.o build/temp.linux-x86_64-2.7/tmp/pip_build_u4591/reportlab/src/rl_addons/renderPM/libart_lgpl/art_rgb_svp.o build/temp.linux-x86_64-2.7/tmp/pip_build_u4591/reportlab/src/rl_addons/renderPM/libart_lgpl/art_svp.o build/temp.linux-x86_64-2.7/tmp/pip_build_u4591/reportlab/src/rl_addons/renderPM/libart_lgpl/art_svp_vpath.o build/temp.linux-x86_64-2.7/tmp/pip_build_u4591/reportlab/src/rl_addons/renderPM/libart_lgpl/art_svp_vpath_stroke.o build/temp.linux-x86_64-2.7/tmp/pip_build_u4591/reportlab/src/rl_addons/renderPM/libart_lgpl/art_svp_ops.o build/temp.linux-x86_64-2.7/tmp/pip_build_u4591/reportlab/src/rl_addons/renderPM/libart_lgpl/art_vpath.o build/temp.linux-x86_64-2.7/tmp/pip_build_u4591/reportlab/src/rl_addons/renderPM/libart_lgpl/art_vpath_dash.o build/temp.linux-x86_64-2.7/tmp/pip_build_u4591/reportlab/src/rl_addons/renderPM/libart_lgpl/art_affine.o build/temp.linux-x86_64-2.7/tmp/pip_build_u4591/reportlab/src/rl_addons/renderPM/libart_lgpl/art_rect.o build/temp.linux-x86_64-2.7/tmp/pip_build_u4591/reportlab/src/rl_addons/renderPM/libart_lgpl/art_rgb_affine.o build/temp.linux-x86_64-2.7/tmp/pip_build_u4591/reportlab/src/rl_addons/renderPM/libart_lgpl/art_rgb_affine_private.o build/temp.linux-x86_64-2.7/tmp/pip_build_u4591/reportlab/src/rl_addons/renderPM/libart_lgpl/art_rgb.o build/temp.linux-x86_64-2.7/tmp/pip_build_u4591/reportlab/src/rl_addons/renderPM/libart_lgpl/art_rgb_rgba_affine.o build/temp.linux-x86_64-2.7/tmp/pip_build_u4591/reportlab/src/rl_addons/renderPM/libart_lgpl/art_svp_intersect.o build/temp.linux-x86_64-2.7/tmp/pip_build_u4591/reportlab/src/rl_addons/renderPM/libart_lgpl/art_svp_render_aa.o build/temp.linux-x86_64-2.7/tmp/pip_build_u4591/reportlab/src/rl_addons/renderPM/libart_lgpl/art_misc.o -L/usr/local/lib -L/usr/lib -L/app/.heroku/python/lib -L/app/.heroku/python/lib -lfreetype -lpython2.7 -o build/lib.linux-x86_64-2.7/reportlab/graphics/_renderPM.so
/usr/bin/ld: /usr/local/lib/libpython2.7.a(abstract.o): relocation R_X86_64_32 against `.rodata.str1.8' can not be used when making a shared object; recompile with -fPIC
/usr/local/lib/libpython2.7.a: could not read symbols: Bad value
collect2: ld returned 1 exit status
error: command 'gcc' failed with exit status 1
----------------------------------------
Cleaning up...
Command /app/.heroku/python/bin/python -c "import setuptools, tokenize;__file__='/tmp/pip_build_u4591/reportlab/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-F4RTRK-record/install-record.txt --single-version-externally-managed --compile failed with error code 1 in /tmp/pip_build_u4591/reportlab
Traceback (most recent call last):
File "/app/.heroku/python/bin/pip", line 9, in <module>
load_entry_point('pip==1.5.6', 'console_scripts', 'pip')()
File "/app/.heroku/python/lib/python2.7/site-packages/pip-1.5.6-py2.7.egg/pip/__init__.py", line 185, in main
return command.main(cmd_args)
File "/app/.heroku/python/lib/python2.7/site-packages/pip-1.5.6-py2.7.egg/pip/basecommand.py", line 161, in main
text = '\n'.join(complete_log)
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 38: ordinal not in range(128)
! Push rejected, failed to compile Python app
To git@heroku.com:mysterious-oasis-7382.git
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'git@heroku.com:mysterious-oasis-7382.git'
Jeromes-MacBook-Pro:diagnosystem_proj Jerome$
感谢您的帮助以解决此问题。
答案 0 :(得分:1)
问题似乎是由/usr/local/lib/libpython2.7.a
中存在静态Python 2.7库引起的;要使用python-2.7.7
运行时正确地在Heroku上安装Reportlab,我更改了Reportlab __call__
文件的inc_lib_dirs
类中setup.py
函数枚举的目录的顺序,如下所示:
<强>原始强>
class inc_lib_dirs:
L = None
I = None
def __call__(self):
if self.L is None:
L = []
I = []
if platform == "cygwin":
aDir(L, os.path.join("/usr/lib", "python%s" % sys.version[:3], "config"))
elif platform == "darwin":
# attempt to make sure we pick freetype2 over other versions
aDir(I, "/sw/include/freetype2")
aDir(I, "/sw/lib/freetype2/include")
# fink installation directories
aDir(L, "/sw/lib")
aDir(I, "/sw/include")
# darwin ports installation directories
aDir(L, "/opt/local/lib")
aDir(I, "/opt/local/include")
aDir(I, "/usr/local/include")
aDir(L, "/usr/local/lib")
aDir(I, "/usr/include")
aDir(L, "/usr/lib")
aDir(I, "/usr/include/freetype2")
prefix = sysconfig.get_config_var("prefix")
if prefix:
aDir(L, pjoin(prefix, "lib"))
aDir(I, pjoin(prefix, "include"))
self.L=L
self.I=I
return self.I,self.L
inc_lib_dirs=inc_lib_dirs()
<强>编辑:强>
class inc_lib_dirs:
L = None
I = None
def __call__(self):
if self.L is None:
L = []
I = []
if platform == "cygwin":
aDir(L, os.path.join("/usr/lib", "python%s" % sys.version[:3], "config"))
elif platform == "darwin":
# attempt to make sure we pick freetype2 over other versions
aDir(I, "/sw/include/freetype2")
aDir(I, "/sw/lib/freetype2/include")
# fink installation directories
aDir(L, "/sw/lib")
aDir(I, "/sw/include")
# darwin ports installation directories
aDir(L, "/opt/local/lib")
aDir(I, "/opt/local/include")
prefix = sysconfig.get_config_var("prefix")
if prefix:
aDir(L, pjoin(prefix, "lib"))
aDir(I, pjoin(prefix, "include"))
aDir(I, "/usr/local/include")
aDir(L, "/usr/local/lib")
aDir(I, "/usr/include")
aDir(L, "/usr/lib")
aDir(I, "/usr/include/freetype2")
self.L=L
self.I=I
return self.I,self.L
inc_lib_dirs=inc_lib_dirs()
我很想找到一个更清洁的解决方案,以避免在我的鸡蛋存储库中保留修改后的版本。