0

I've been trying to learn Python via "Learn Python the Hard Way", and in ex46 he told us to put a script in bin and install it with setup.py.

My script name was script1.py Here is my setup.py file:

try:
    from setuptools import setup
except ImportError:
    from distutils.core import setup

config = [
          'description': 'My Project',
          'author': 'My Name',
          'url': 'URL to get it at.',
          'download_url': 'Where to download it.',
          'author_email': 'My email.',
          'version': '0.1',
          'install_requires': ['nose'],
          'packages': ['NAME'],
          'scripts': ['bin/script1.py'],
          'name': 'projectname'
        ]
setup(**config)

Output:

File "setup.py", line 7
'description': 'My Project',
             ^
SyntaxError: invalid syntax
  • I am using ubuntu 16.04 and python 2.7.13
5
  • 3
    FWIW, the SO Python Chat room regulars do not recommend LPTHW. If it's working for you, that's great, but please be aware that there are several problems with this book. Also be aware that Python 2 will reach its End Of Life in 2020, so you really ought to be learning Python 3, unless you need Python 2 to work on legacy code. Commented Jun 9, 2017 at 21:47
  • @PM2Ring Thank you, sir. I am about to finish this book and then I will move to leaning python 3. Is python 3 completely different from python 2.7 ? Commented Jun 9, 2017 at 23:05
  • No, Python 3 isn't completely different from python 2.7, but there are some important differences. In particular, Python 3 makes a clear distinction between text and bytes, which allows it to have better handling of Unicode. Commented Jun 10, 2017 at 10:32
  • Learning Python 2 is waste of time now, as you're using Ubuntu 16.04, and Python 3 can be run with the simple python3 command - it is preinstalled as most of the Python scripts on the operating system require Python 3. Commented Jun 12, 2017 at 4:25
  • I wouldn't say learning Python 2 is a waste of time, but I would strongly recommend dedicating your effort to Python 3 instead. Commented Jun 12, 2017 at 15:14

1 Answer 1

2

Your description is shown as a list (begins and ends with [ and ]) but should be a dict (begin and end with { and }).

A list is just that, a comma separated list of items, the start and end of which are indicated by brackets ([ and ]). A dict on the other hand is a comma separated list of key/value pairs which are indicated by braces({ and }). The error is telling you that the colon (which would separate a dictionary's key from its value) is out of place since it thinks it is a list. By changing the beginning and ending brackets to braces, it will properly identify it as a dictionary.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.