简体   繁体   中英

python setup.py sdist - SyntaxError: invalid syntax

when I run the 'python setup.py sdist', i always meet with an error'SyntaxError: invalid syntax'.

the following is my source code:

printlist.py

def printlist(the_list):
for eachitem in the_list:
    print(eachitem)

setup.py

from distutils.core import setup
setup(name='printlist',version='1.0',py_modules = ['printlist'])

both of these two files are placed in the same folder named 'myfolder'. and the version of Python is 3.2 on Windows XP platfrom.

Any ideas or options are appreciated!!!

You are missing a comma after ['printlit']

It should look like this

setup(
    name='printlist',
    version='1.0',
    py_modules = ['printlist'],
)

As Josh Caswell and pynator said, the syntax error likely comes from printlist.py, which should be intended like

def printlist(the_list):
    for eachitem in the_list:
        print(eachitem)

That said, I do not get any error when running python setup.py sdist on your programs with Python 3.2 on Mac OS X: distutils does not try to import your printlist.py module. So, giving more details about the precise error you get, in your question, would be useful.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM