在cx冻结中创建msi - 在reportlab中进行模块化

时间:2014-08-20 19:38:56

标签: python python-2.7 cx-freeze reportlab

我正在尝试在cx_freeze中创建一个可分发的python脚本。当我运行它时,我收到此错误:

ImportError: No module named lib

我的程序中引用的行是

from reportlab.lib import colors, utils

我没有在setup.py中指定包。这个特定程序的输出是一个pdf报告,用Reportlab编写。我还使用PyQt4,matplotlib,numpy和mpl_toolkits。在大多数这些中,我导入了特定的模块。有没有办法改变包裹?或任何其他方式做我想要的?目标是一个可安装的程序,以便同事可以在我缺席的情况下生成报告,而无需实际安装Python和配件。


ETA

这是我的setup.py:

import sys
from cx_Freeze import setup, Executable

base = None

build_exe_options = {"packages": ["os",'sys', 'PyQt4','reportlab', 'csv', 'numpy', 'matplotlib']}


if sys.platform == 'win32':
    base = 'Win32GUI'

setup(  name = "XY grouped plots",
        version = "0.1",
        description = "Contact <myworkemail> with questions",
        options = {"build_exe" : build_exe_options},
        executables = [Executable("XY_grouped_plots.pyw", base=base)])

以下是我在程序中使用的导入:

import sys
from PyQt4 import QtGui, QtCore
from PyQt4.QtGui import *   #yes, I know this should be covered above
from PyQt4.QtCore import * #but for some reason when I only do that, it gives me errors. 
from reportlab.lib import colors, utils
import csv
import numpy as np
from reportlab.pdfgen import canvas
from reportlab.lib.pagesizes import letter, landscape
from reportlab.lib.units import inch
from reportlab.platypus import SimpleDocTemplate, Table, TableStyle, Image, PageBreak, KeepTogether
from reportlab.lib.styles import ParagraphStyle as PS
from reportlab.lib.enums import TA_CENTER
from reportlab.platypus.paragraph import Paragraph
import matplotlib.pyplot as plt
import matplotlib as mpl

这是我在上面添加软件包时遇到的错误:

raise ImportError("No module named %r" %subModuleName)
ImportError: No module named 'PyQt4.uic.port_v3.proxy_base'

我的进口太宽了吗?当我让cx_freeze选择导入时,我遇到了reportlab的问题(当我构建msi文件时没有错误)。现在,当我尝试制作msi文件时,它会抛出此错误。

1 个答案:

答案 0 :(得分:1)

I happened this question, after I remove 'PyQt4' from packages ,build success!