3

I have a project in this structure on my linux machine:

project/
       changelog
       README
       src/
          install.sh
          myproject.py
          modules/
                 a.py 
                 b.py
                 __init__.py

Now I want to use cx_freeze for building my project:

import sys
from cx_Freeze import setup,Executable

includefiles = ['changelog', 'README', 'src/install.sh']
executable = ['src/myproject.py', 'src/modules/a.py',  'src/modules/b.py', 'src/modules/__init__.py']
includes = []
excludes = []
packages = []

setup(
    name = 'myproject',
    version = '0.1',
    description = 'A general enhancement utility',
    author = 'user',
    author_email = 'mail@gmail.com',
    options = {'build_exe': {'excludes':excludes,'packages':packages,'include_files':includefiles}},
    executables = [Executable(executable)]

I do:

$ python setup.py build

But the following error occurs:

AttributeError: 'list' object has no attribute 'rfind'
MLSC
  • 5,872
  • 8
  • 55
  • 89

1 Answers1

1

You assign an array to executable variable

executable = ['src/myproject.py', 'src/modules/a.py',  'src/modules/b.py', 'src/modules/__init__.py']

but it should be a string. Please refer to manual. An example from the manual:

setup(  name = "guifoo",
        version = "0.1",
        description = "My GUI application!",
        options = {"build_exe": build_exe_options},
        executables = [Executable("guifoo.py", base=base)])
MartyIX
  • 27,828
  • 29
  • 136
  • 207
  • Instead of `"guifoo.py"` (i.e. a string) you assign `['src/myproject.py', 'src/modules/a.py', 'src/modules/b.py', 'src/modules/__init__.py']` (i.e. an array). And an array does not have `rfind` method defined. I don't know how to say it more clearly. Maybe try to reformulate your question if you don't understand what I mean. – MartyIX Dec 21 '15 at 10:35
  • So how can I change it? – MLSC Dec 21 '15 at 10:40
  • I believe it should be `executable="src/myproject.py"` (http://stackoverflow.com/questions/9895636/how-do-i-use-cx-freeze) – MartyIX Dec 21 '15 at 10:45
  • Ok..But other modules aren't copied...like src/modules/a.py ETC – MLSC Dec 21 '15 at 10:49
  • 1
    I'm sorry, I don't know. This http://stackoverflow.com/questions/25938252/cx-freeze-and-importing-modules looks like a similar question to yours. – MartyIX Dec 21 '15 at 10:56