robbrad / UKBinCollectionData

UK Council Bin Collection Data Parser Outputting Bin Data as a JSON
MIT License
121 stars 82 forks source link

Syntax Error #5

Closed Mod74 closed 1 year ago

Mod74 commented 4 years ago

Hi, I think I have this working from a Home Assistant / Python point of view, however when I run I get a Python Syntax error

Syntax errors detected :

Line 26: data[f'{binType}'] = f'{binCollection}' ^ SyntaxError: invalid syntax

I know next to nothing about coding so I tried checking here https://extendsclass.com/python-tester.html and it shows the same error. I checked the other bin collection scripts and the one that is similar to this throws the same error, but the ones that are completely different doesn't. I checked pythonbuddy.com and it said "Format strings are only supported in Python 3.6 and greater (, line 26)" however I have 3.7 installed as Home Assistant required it and the venv was set up using it. I tried to shebang the specific version 3.7.3 and it still threw the syntax error. Any idea?

Originally posted by @Mod74 in https://github.com/robbrad/UKBinCollectionData/issues/3#issuecomment-581027291

robbrad commented 4 years ago

Hi @Mod74

I have removed the f strings from the commit https://github.com/robbrad/UKBinCollectionData/commit/c4facec163b2c1aa1f7fea5e1772b9a9634aaabd

Can you try again?

My worry is the next error you will be ImportError: No module named 'bs4'

How are you running this? and can you try the following as a script.

import sys
print(sys.version)
Mod74 commented 4 years ago

Hi,

Thank you again for looking at this. When I try the new code I get

Traceback (most recent call last):
  File "durhamccbins.py", line 2, in <module>
    from urllib.request import Request, urlopen
ImportError: No module named request

I manually added beautiful soup so I guess it's found it, or maybe not.

I tried installing urllib and it said it was already installed.

When I run the version command script I get

2.7.16 (default, Oct 10 2019, 22:02:15)
[GCC 8.3.0]

I was hoping to run this using the HA Python method, as that seemed easier as I'm on a Pi venv, but the tests above are done by SSH into the Pi and then running pyton filename.py from the command line. However I'm far far from an expert on these things so I dunno, it could be running beautifully in the original version of the code but I'm just doing something else wrong.

dp247 commented 1 year ago

Project has been rewritten since this, so going to preliminary close. Feel free to reopen if its still an issue though.