1

我有一个要打包的应用程序,其中包含一个图像作为数据文件,我尝试运行这个 setup.py 脚本:

from distutils.core import setup
import py2exe
import matplotlib

file_dati=[]
file_dati.append(matplotlib.get_py2exe_datafiles())
file_dati.append(('img1','C:\Users\MZompetta.000\Desktop\20130114_assortimenti\img1.gif'))

setup(console=[{"script": "Int_assortimenti.py"}],
       options = {
        "py2exe": {
            "dll_excludes": ["libzmq.dll", "MSVCP90.dll"]
        }
    }, data_files=file_dati
)

但我收到此错误:

AttributeError:“元组”对象没有属性“拆分”

错误是指该行:data_files=file_dati

我尝试了其他方法来编写 data_files 但没有办法。

任何人都可以帮助我吗?

4

1 回答 1

1
import os
import logging
from distutils.core import setup
import py2exe
import matplotlib
import shutil

distDir = "dist"

# Remove the build and dist folders
shutil.rmtree("build", ignore_errors=True)
shutil.rmtree("dist", ignore_errors=True)

try:
    os.mkdir(os.path.abspath(distDir))
except:
    logging.exception('')

data_files = matplotlib.get_py2exe_datafiles()
shutil.copyfile('C:\Users\MZompetta.000\Desktop\20130114_assortimenti\img1.gif', os.path.join(distDir, "img1.gif"))

setup(
    options = {"py2exe": {
            "dll_excludes": ["libzmq.dll", "MSVCP90.dll"],
            "dist_dir": distDir,
        }
    }
    data_files = data_files,
    console=[{"script": "Int_assortimenti.py"}],
)
于 2013-01-15T00:50:17.593 回答