Reputation: 21
When I import gcsfs in datalab,
import gcsfs
I've this invalid syntax error which is related to the package fsspec. Is it something to do with versions
File "/usr/local/envs/py3env/lib/python3.5/site-packages/IPython/core/interactiveshell.py", line 2961, in run_code
exec(code_obj, self.user_global_ns, self.user_ns)
File "<ipython-input-3-3f25f74e3f1b>", line 1, in <module>
import gcsfs
File "/usr/local/envs/py3env/lib/python3.5/site-packages/gcsfs/__init__.py", line 5, in <module>
from .core import GCSFileSystem
File "/usr/local/envs/py3env/lib/python3.5/site-packages/gcsfs/core.py", line 7, in <module>
import fsspec
File "/usr/local/envs/py3env/lib/python3.5/site-packages/fsspec/__init__.py", line 10, in <module>
from .mapping import FSMap, get_mapper
File "/usr/local/envs/py3env/lib/python3.5/site-packages/fsspec/mapping.py", line 2, in <module>
from .core import url_to_fs
File "/usr/local/envs/py3env/lib/python3.5/site-packages/fsspec/core.py", line 314
out[0] = (f"{out[0][1]}://", out[0][1], out[0][2])
^
SyntaxError: invalid syntax
Upvotes: 2
Views: 1302
Reputation: 370
To expand on Claros answer, the underlying problem is the fsspec package, which gcsfs inherits from. fsspec's recent 0.8.0 version implemented f-strings, which is causing the error. To fix it, simply install the latest fsspec version that still supports Python 3.5, i.e.
!pip install fsspec==0.6.2
https://pypi.org/project/fsspec/0.6.2/
You may also have to downgrade gcsfs. I got it to work with
!pip install --upgrade gcsfs==0.5.3
Upvotes: 2
Reputation: 107
You're using Python 3.5, while f-strings is a feature implemented in Python 3.6. Either you find a compatible version of your package with Python 3.5, or you upgrade to Python 3.6+.
Upvotes: 0