0

So, here I am, playing around with the ipfsapi in python and yesterday, to start somewhere, I ran some code from the following blogpost that connects to the local node: https://medium.com/python-pandemonium/getting-started-with-python-and-ipfs-94d14fdffd10

Last night it worked perfectly, but today when I began a new project where I would actually use this method and rewrote the code, I got an invalid syntax error in the except statement. Right now the code looks like this

    if __name__ == '__main__':
        try:
            api = ipfshttpclient.connect('127.0.0.1', 5001)
            print(api)
        except: ipfshttpclient.exceptions.ConnectionError as ce: #the invalid syntax error is marked at as
            print(str(ce))

Traceback:

File "/home/", line 17
    except: ipfshttpclient.exceptions.ConnectionError as ce:
                                                       ^
SyntaxError: invalid syntax

The odd thing is that I'm getting an invalid syntax error on the as. I've changed ipfsapi due to deprecation warning to ipfshttpclient, but it doesn't work with either now, same erreor. How is that even possible? Am I just not seeing something I should? Is my brain smoothing out? Sorry if it's a dumb issue and thanks in advance!

Python 3.7.4 64-bit | Qt 5.9.6 | PyQt5 5.9.2 | Linux 5.5.10-arch1-1

8NTFae
  • 11
  • 3
  • 1
    Please update your question with the full traceback. – quamrana Mar 21 '20 at 15:00
  • 3
    try remove the colon in your `except` part – kucing_terbang Mar 21 '20 at 15:04
  • If you truly think it is unexplainable then you would not seek an explanation here. Please avoid hyperbole like this when writing on Stack Overflow. – kaya3 Mar 21 '20 at 15:06
  • It was the colon, sorry for the dumb question and the hyperbole. Now I'll just drink some coffee in shame. Thanks for all taking the time! – 8NTFae Mar 21 '20 at 15:09
  • No problem, at least it helped you fix your code. This question is likely to be closed as "caused by a typo or a problem that can no longer be reproduced", but don't take that personally - it just means the question and answer are unlikely to be useful to other readers. – kaya3 Mar 21 '20 at 15:14

1 Answers1

1

You should remove the colon : after the except.

IkarosKun
  • 463
  • 3
  • 15