Search code examples
pythonpy2exe

SyntaxError on setup.py


I am new to python and I am trying to make an exe file, using py2exe, from a python code I made. I made the following setup.py file following a tutorial on how to use py2exe:

from distutils.core import setup
from glob import glob
import py2exe

setup(console=['App.py'])

data_files = [("msvcr90.dll", glob(r'C:\Windows\winsxs\x86_microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.21022.8_none_bcb86ed6ac711f91\msvcr90.dll\*.*'))]
setup(data_files=data_files, etc)

sys.path.append("C:\Windows\winsxs\x86_microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.21022.8_none_bcb86ed6ac711f91\msvcr90.dll")

When I try to run it in cmd I get the following error:

SyntaxError: non-keyword arg after keyword arg

I have read several other posts on this error basically saying that I should have the "etc" before "data_files". However when I do this, I get a name error undefined name sys.

I want to include msvcr90.dll file with the setup.py

Any ideas on how to fix this?


Solution

  • I have read several other posts on this error basically saying that I should have the "etc" before "data_files". However when I do this, I get a name error undefined name sys

    That IS the solution to this problem, though you will then encounter the same error with etc as it is not defined anywhere (I believe it is meant to be an example to show that setup can accept other arguments, and not meant to be used literally in your code).

    You are getting undefined name sys because that is another, unrelated issue in your code.

    You should add import sys.

    from distutils.core import setup
    from glob import glob
    import py2exe
    import sys
    
    setup(console=['App.py'])
    
    data_files = [("msvcr90.dll", glob(r'C:\Windows\winsxs\x86_microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.21022.8_none_bcb86ed6ac711f91\msvcr90.dll\*.*'))]
    setup(data_files=data_files)
    
    sys.path.append("C:\Windows\winsxs\x86_microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.21022.8_none_bcb86ed6ac711f91\msvcr90.dll")