在 datalab 中导入 gcsfs 出现错误 [英] Importing gcsfs in datalab is giving an error
问题描述
当我在 datalab 中导入 gcsfs 时,
导入 gcsfs
我有这个与 fsspec 包相关的无效语法错误.是不是跟版本有关
<预><代码>文件/usr/local/envs/py3env/lib/python3.5/site-packages/IPython/core/interactiveshell.py",第 2961 行,在 run_code 中exec(code_obj,self.user_global_ns,self.user_ns)文件<ipython-input-3-3f25f74e3f1b>",第 1 行,在 <module>导入 gcsfs文件/usr/local/envs/py3env/lib/python3.5/site-packages/gcsfs/__init__.py",第5行,在<module>从 .core 导入 GCSFileSystem文件/usr/local/envs/py3env/lib/python3.5/site-packages/gcsfs/core.py",第7行,在<module>导入 fsspec文件/usr/local/envs/py3env/lib/python3.5/site-packages/fsspec/__init__.py",第 10 行,在为了扩展 Claros 的答案,潜在的问题是 gcsfs 继承的 fsspec 包.fsspec 最近的 0.8.0 版本实现了 f-strings,这会导致错误.要修复它,只需安装仍支持 Python 3.5 的最新 fsspec 版本,即
!pip install fsspec==0.6.2
https://pypi.org/project/fsspec/0.6.2/一个>
您可能还需要降级 gcsfs.我得到它的工作
!pip install --upgrade gcsfs==0.5.3
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
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
这篇关于在 datalab 中导入 gcsfs 出现错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!