Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invalid Syntax #107

Open
izzybella49 opened this issue Jul 12, 2018 · 3 comments
Open

Invalid Syntax #107

izzybella49 opened this issue Jul 12, 2018 · 3 comments

Comments

@izzybella49
Copy link

My Smart Mirror gave me this message when I tried to run it:
pi@raspberrypi:~/Smart-Mirror $ python smartmirror.py
File "smartmirror.py", line 130
except Exception as e:

SyntaxError: invalid syntax

Thanks in advance

@izzybella49
Copy link
Author

def get_ip(self):
try:
ip_url = "https://ipstack.com"
req = requests.get(ip_url)
ip_json = json.loads(req.text)
return ip_json['75.148.185.113']
except Exception as e:

               traceback.print_exc(e)
        return "Error: %s. Cannot get ip." % e

This is the code can someone please spot something wrong with my code.

@big1surg
Copy link

def get_ip(self):
try:
ip_url = "http://jsonip.com/"
req = requests.get(ip_url)
ip_json = json.loads(req.text)
return ip_json['ip']
except Exception as e:
traceback.print_exc()
return "Error: %s. Cannot get ip." % e

@dangercrow
Copy link

https://docs.python.org/2/tutorial/errors.html

Sounds like you're using python 3 syntax on python 2 code.

As the above link says, it's catch Exception, e: in old python

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants