在 python django 服务 ubuntu 中安装 reportLab

Posted

技术标签:

【中文标题】在 python django 服务 ubuntu 中安装 reportLab【英文标题】:installing reportLab in python django service ubuntu 【发布时间】:2016-01-14 18:55:22 【问题描述】:

在python django服务中生成pdf报告尝试在env中安装reportLab

pip install ReportLab

显示错误枕头,我认为 reportLab 的某些依赖项抛出错误

Requirement already satisfied (use --upgrade to upgrade): pip>=1.4.1 

in /home/phoenix/djenv/lib/python2.7/site-packages (from ReportLab)
Collecting pillow>=2.4.0 (from ReportLab)
  Using cached Pillow-3.0.0.tar.gz
Requirement already satisfied (use --upgrade to upgrade): setuptools>=2.2 in /home/phoenix/djenv/lib/python2.7/site-packages (from ReportLab)
Installing collected packages: pillow, ReportLab
  Running setup.py install for pillow
    Complete output from command /home/phoenix/djenv/bin/python -c "import setuptools, tokenize;__file__='/tmp/pip-build-0ocjqD/pillow/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-dAEFWI-record/install-record.txt --single-version-externally-managed --compile --install-headers /home/phoenix/djenv/include/site/python2.7/pillow:
    running install
    running build
    running build_py
    creating build
    creating build/lib.linux-x86_64-2.7
    creating build/lib.linux-x86_64-2.7/PIL
    copying PIL/ImagePalette.py -> build/lib.linux-x86_64-2.7/PIL
    copying PIL/PdfImagePlugin.py -> build/lib.linux-x86_64-2.7/PIL
    copying PIL/Hdf5StubImagePlugin.py -> build/lib.linux-x86_64-2.7/PIL
    copying PIL/ImageTransform.py -> build/lib.linux-x86_64-2.7/PIL
    copying PIL/MspImagePlugin.py -> build/lib.linux-x86_64-2.7/PIL
    copying PIL/DcxImagePlugin.py -> build/lib.linux-x86_64-2.7/PIL
    copying PIL/GribStubImagePlugin.py -> build/lib.linux-x86_64-2.7/PIL
    copying PIL/BmpImagePlugin.py -> build/lib.linux-x86_64-2.7/PIL
    copying PIL/ImageMode.py -> build/lib.linux-x86_64-2.7/PIL
    copying PIL/XbmImagePlugin.py -> build/lib.linux-x86_64-2.7/PIL
    copying PIL/TiffImagePlugin.py -> build/lib.linux-x86_64-2.7/PIL
    copying PIL/FitsStubImagePlugin.py -> build/lib.linux-x86_64-2.7/PIL
    copying PIL/ImageOps.py -> build/lib.linux-x86_64-2.7/PIL
    copying PIL/ImImagePlugin.py -> build/lib.linux-x86_64-2.7/PIL
    copying PIL/_binary.py -> build/lib.linux-x86_64-2.7/PIL
    copying PIL/PixarImagePlugin.py -> build/lib.linux-x86_64-2.7/PIL
    copying PIL/MicImagePlugin.py -> build/lib.linux-x86_64-2.7/PIL
    copying PIL/ImagePath.py -> build/lib.linux-x86_64-2.7/PIL
    copying PIL/PsdImagePlugin.py -> build/lib.linux-x86_64-2.7/PIL
    copying PIL/ImageDraw.py -> build/lib.linux-x86_64-2.7/PIL
    copying PIL/WmfImagePlugin.py -> build/lib.linux-x86_64-2.7/PIL
    copying PIL/BdfFontFile.py -> build/lib.linux-x86_64-2.7/PIL
    copying PIL/ImageCms.py -> build/lib.linux-x86_64-2.7/PIL
    copying PIL/PyAccess.py -> build/lib.linux-x86_64-2.7/PIL
    copying PIL/ExifTags.py -> build/lib.linux-x86_64-2.7/PIL
    copying PIL/FpxImagePlugin.py -> build/lib.linux-x86_64-2.7/PIL
    copying PIL/ImageGrab.py -> build/lib.linux-x86_64-2.7/PIL
    copying PIL/TarIO.py -> build/lib.linux-x86_64-2.7/PIL
    copying PIL/PcfFontFile.py -> build/lib.linux-x86_64-2.7/PIL
    copying PIL/ContainerIO.py -> build/lib.linux-x86_64-2.7/PIL
    copying PIL/PaletteFile.py -> build/lib.linux-x86_64-2.7/PIL
    copying PIL/ImageTk.py -> build/lib.linux-x86_64-2.7/PIL
    copying PIL/IcnsImagePlugin.py -> build/lib.linux-x86_64-2.7/PIL
    copying PIL/CurImagePlugin.py -> build/lib.linux-x86_64-2.7/PIL
    copying PIL/EpsImagePlugin.py -> build/lib.linux-x86_64-2.7/PIL
    copying PIL/FontFile.py -> build/lib.linux-x86_64-2.7/PIL
    copying PIL/ImageDraw2.py -> build/lib.linux-x86_64-2.7/PIL
    copying PIL/Jpeg2KImagePlugin.py -> build/lib.linux-x86_64-2.7/PIL
    copying PIL/ImageFilter.py -> build/lib.linux-x86_64-2.7/PIL
    copying PIL/ImageShow.py -> build/lib.linux-x86_64-2.7/PIL
    copying PIL/ImtImagePlugin.py -> build/lib.linux-x86_64-2.7/PIL
    copying PIL/GifImagePlugin.py -> build/lib.linux-x86_64-2.7/PIL
    copying PIL/ImageEnhance.py -> build/lib.linux-x86_64-2.7/PIL
    copying PIL/ImageSequence.py -> build/lib.linux-x86_64-2.7/PIL
    copying PIL/SunImagePlugin.py -> build/lib.linux-x86_64-2.7/PIL
    copying PIL/features.py -> build/lib.linux-x86_64-2.7/PIL
    copying PIL/GimpPaletteFile.py -> build/lib.linux-x86_64-2.7/PIL
    copying PIL/IptcImagePlugin.py -> build/lib.linux-x86_64-2.7/PIL
    copying PIL/PcdImagePlugin.py -> build/lib.linux-x86_64-2.7/PIL
    copying PIL/ImageFile.py -> build/lib.linux-x86_64-2.7/PIL
    copying PIL/WalImageFile.py -> build/lib.linux-x86_64-2.7/PIL
    copying PIL/PpmImagePlugin.py -> build/lib.linux-x86_64-2.7/PIL
    copying PIL/PalmImagePlugin.py -> build/lib.linux-x86_64-2.7/PIL
    copying PIL/BufrStubImagePlugin.py -> build/lib.linux-x86_64-2.7/PIL
    copying PIL/_util.py -> build/lib.linux-x86_64-2.7/PIL
    copying PIL/Image.py -> build/lib.linux-x86_64-2.7/PIL
    copying PIL/TgaImagePlugin.py -> build/lib.linux-x86_64-2.7/PIL
    copying PIL/MpoImagePlugin.py -> build/lib.linux-x86_64-2.7/PIL
    copying PIL/ImageWin.py -> build/lib.linux-x86_64-2.7/PIL
    copying PIL/ImageQt.py -> build/lib.linux-x86_64-2.7/PIL
    copying PIL/ImageColor.py -> build/lib.linux-x86_64-2.7/PIL
    copying PIL/OleFileIO.py -> build/lib.linux-x86_64-2.7/PIL
    copying PIL/ImageChops.py -> build/lib.linux-x86_64-2.7/PIL
    copying PIL/ImageFont.py -> build/lib.linux-x86_64-2.7/PIL
    copying PIL/GdImageFile.py -> build/lib.linux-x86_64-2.7/PIL
    copying PIL/ImageMorph.py -> build/lib.linux-x86_64-2.7/PIL
    copying PIL/ImageStat.py -> build/lib.linux-x86_64-2.7/PIL
    copying PIL/GbrImagePlugin.py -> build/lib.linux-x86_64-2.7/PIL
    copying PIL/SpiderImagePlugin.py -> build/lib.linux-x86_64-2.7/PIL
    copying PIL/McIdasImagePlugin.py -> build/lib.linux-x86_64-2.7/PIL
    copying PIL/PSDraw.py -> build/lib.linux-x86_64-2.7/PIL
    copying PIL/WebPImagePlugin.py -> build/lib.linux-x86_64-2.7/PIL
    copying PIL/FliImagePlugin.py -> build/lib.linux-x86_64-2.7/PIL
    copying PIL/IcoImagePlugin.py -> build/lib.linux-x86_64-2.7/PIL
    copying PIL/MpegImagePlugin.py -> build/lib.linux-x86_64-2.7/PIL
    copying PIL/ImageMath.py -> build/lib.linux-x86_64-2.7/PIL
    copying PIL/TiffTags.py -> build/lib.linux-x86_64-2.7/PIL
    copying PIL/JpegPresets.py -> build/lib.linux-x86_64-2.7/PIL
    copying PIL/PngImagePlugin.py -> build/lib.linux-x86_64-2.7/PIL
    copying PIL/JpegImagePlugin.py -> build/lib.linux-x86_64-2.7/PIL
    copying PIL/XVThumbImagePlugin.py -> build/lib.linux-x86_64-2.7/PIL
    copying PIL/XpmImagePlugin.py -> build/lib.linux-x86_64-2.7/PIL
    copying PIL/PcxImagePlugin.py -> build/lib.linux-x86_64-2.7/PIL
    copying PIL/SgiImagePlugin.py -> build/lib.linux-x86_64-2.7/PIL
    copying PIL/GimpGradientFile.py -> build/lib.linux-x86_64-2.7/PIL
    copying PIL/__init__.py -> build/lib.linux-x86_64-2.7/PIL
    running egg_info
    writing Pillow.egg-info/PKG-INFO
    writing top-level names to Pillow.egg-info/top_level.txt
    writing dependency_links to Pillow.egg-info/dependency_links.txt
    warning: manifest_maker: standard file '-c' not found

    reading manifest file 'Pillow.egg-info/SOURCES.txt'
    reading manifest template 'MANIFEST.in'
    writing manifest file 'Pillow.egg-info/SOURCES.txt'
    copying PIL/OleFileIO-README.md -> build/lib.linux-x86_64-2.7/PIL
    running build_ext
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/tmp/pip-build-0ocjqD/pillow/setup.py", line 767, in <module>
        zip_safe=not debug_build(),
      File "/usr/lib/python2.7/distutils/core.py", line 151, in setup
        dist.run_commands()
      File "/usr/lib/python2.7/distutils/dist.py", line 953, in run_commands
        self.run_command(cmd)
      File "/usr/lib/python2.7/distutils/dist.py", line 972, in run_command
        cmd_obj.run()
      File "/home/phoenix/djenv/local/lib/python2.7/site-packages/setuptools/command/install.py", line 61, in run
        return orig.install.run(self)
      File "/usr/lib/python2.7/distutils/command/install.py", line 601, in run
        self.run_command('build')
      File "/usr/lib/python2.7/distutils/cmd.py", line 326, in run_command
        self.distribution.run_command(command)
      File "/usr/lib/python2.7/distutils/dist.py", line 972, in run_command
        cmd_obj.run()
      File "/usr/lib/python2.7/distutils/command/build.py", line 128, in run
        self.run_command(cmd_name)
      File "/usr/lib/python2.7/distutils/cmd.py", line 326, in run_command
        self.distribution.run_command(command)
      File "/usr/lib/python2.7/distutils/dist.py", line 972, in run_command
        cmd_obj.run()
      File "/usr/lib/python2.7/distutils/command/build_ext.py", line 337, in run
        self.build_extensions()
      File "/tmp/pip-build-0ocjqD/pillow/setup.py", line 515, in build_extensions
        % (f, f))
    ValueError: --enable-jpeg requested but jpeg not found, aborting.

    ----------------------------------------
Command "/home/phoenix/djenv/bin/python -c "import setuptools, tokenize;__file__='/tmp/pip-build-0ocjqD/pillow/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-dAEFWI-record/install-record.txt --single-version-externally-managed --compile --install-headers /home/phoenix/djenv/include/site/python2.7/pillow" failed with error code 1 in /tmp/pip-build-0ocjqD/pillow

就这样结束了

还尝试了一些解决方案,例如添加此标志

export CFLAGS=-Qunused-arguments
export CPPFLAGS=-Qunused-arguments

【问题讨论】:

尝试单独安装枕头 pip install枕头==2.4.0 最终像 x86_64-linux-gnu-gcc: 错误:无法识别的命令行选项 '-Qunused-arguments' x86_64-linux-gnu-gcc :错误:无法识别的命令行选项“-Qunused-arguments”错误:命令“x86_64-linux-gnu-gcc”失败,退出状态为 1 不要在里面提到版本号,只要 pip install 枕头就行了 尝试安装 python-dev、libevent-dev。 sudo apt-get install python-dev libevent-dev。然后尝试重新安装枕头 【参考方案1】:

来自Reportlab python package index

2.1 一般先决条件

您需要安装 Python(版本 2.7 或 >=3.3), 理想情况下,PIL 或 Pillow 支持 Freetype;

试试

pip install pillow

然后重试安装reportlab

编辑:

对于您提到的错误,请尝试安装常见的依赖项:

sudo apt-get install build-essential autoconf libtool pkg-config python-opengl python-imaging python-pyrex python-pyside.qtopengl idle-python2.7 qt4-dev-tools qt4-designer libqtgui4 libqtcore4 libqt4-xml libqt4-test libqt4-script libqt4-network libqt4-dbus python-qt4 python-qt4-gl libgle3 python-dev libjpeg-dev libpng-dev zlib1g-dev

【讨论】:

python --version Python 2.7.9 这很好阿伦,只需尝试安装 pip install 枕头,然后 pip install ReportLab。 已经尝试过 'pip install枕头' " x86_64-linux-gnu-gcc: 错误: 无法识别的命令行选项 '-Qunused-arguments' " " x86_64-linux-gnu-gcc: 错误: 无法识别的命令行选项“-Qunused-arguments”“”错误:命令“x86_64-linux-gnu-gcc”失败,退出状态为 1“ 之前的错误消失了“ ValueError: --enable-jpeg requested but jpeg not found, aborting.” reportlab 安装成功了吗?您何时何地收到此错误?

以上是关于在 python django 服务 ubuntu 中安装 reportLab的主要内容,如果未能解决你的问题,请参考以下文章

django之部署到ubuntu服务器上

Python 关于在ubuntu部署Django项目

ubuntu云服务器搭建django项目

ubuntu 16.04部署python项目(Nginx+uwsgi+django)

Python3 + django2.0 + apache2 + ubuntu14部署网站上线

阿里云服务器,linux, ubuntu ,部署django用到的一些命令