-1

I am using Py2exe to create a executable app for my GUI and this is my setup code:

import matplotlib
from distutils.core import setup
import FileDialog
import zmq.libzmq

import py2exe
setup(
 data_files=[matplotlib.get_py2exe_datafiles(),(zmq.libzmq.__file__,)],
 console = [{'script': 'SVS-virtual-lib2.py'}],
 options={
         'py2exe': {
                 'packages': ['FileDialog'],
                 'includes': ['zmq.backend.cython'],
                 'excludes': ['zmq.libzmq'],
                 'dll_excludes': ['libzmq.pyd']
                 }
        }
)

But i get the following error:

  File "C:\Users\nzarinabad\AppData\Local\Continuum\Anaconda\lib\distutils\util.py", line 128, in convert_path
    paths = string.split(pathname, '/')
  File "C:\Users\nzarinabad\AppData\Local\Continuum\Anaconda\lib\string.py", line 294, in split
    return s.split(sep, maxsplit)
AttributeError: 'tuple' object has no attribute 'split

Dose anyone who why i get the error and how to fix it? Thank you

Blckknght
  • 100,903
  • 11
  • 120
  • 169
  • I don't know `distutils` or `py2exe` at all well, but I'd guess that `data_files` is supposed to be a sequence of strings, not a nested list of lists. Try `data_files=matplotlib.get_py2exe_datafiles() + [zmq.libzmq.__file__]` perhaps? – Blckknght Jul 17 '15 at 11:27
  • possible duplicate of [using py2exe with wxPython and Matplotlib](http://stackoverflow.com/questions/6488606/using-py2exe-with-wxpython-and-matplotlib) – Peter Wood Jul 17 '15 at 11:42

1 Answers1

1

Please see the documentation, if you want to combine matplotlib.get_py2exe_datafiles() with other files, you have to do some manual work:

from distutils.core import setup
import py2exe

from distutils.filelist import findall
import os
import matplotlib
matplotlibdatadir = matplotlib.get_data_path()
matplotlibdata = findall(matplotlibdatadir)
matplotlibdata_files = []
for f in matplotlibdata:
    dirname = os.path.join('matplotlibdata', f[len(matplotlibdatadir)+1:])
    matplotlibdata_files.append((os.path.split(dirname)[0], [f]))

matplotlibdata_files.append(zmq.libzmq.__file__)

# ...

setup(
 data_files=matplotlibdata_files,
# rest of your code
Burhan Khalid
  • 169,990
  • 18
  • 245
  • 284
  • Thank you for your answer, I changed that, but still getting same error. File "C:\Users\nzarinabad\AppData\Local\Continuum\Anaconda\lib\string.py", line 294, in split return s.split(sep, maxsplit) AttributeError: 'tuple' object has no attribute 'split' When I run my GUI itself in python it works fine, can it be something in my gui code? – Niloufar Zarin Jul 17 '15 at 11:31