dvc (data version control) error - ImportError: cannot import name 'fsspec_loop' from 'fsspec.asyn'

7k Views Asked by At

I use Python version 3.7.13 and create a virtual environment (venv) for a MLOps project.

A dvc package (=2.10.2) that is compatible with Python== 3.7.13 is installed in this venv.

(venv) (base) tony3@Tonys-MacBook-Pro mlops % dvc --version
2.10.2

But when running the dvc initiation:

(venv) (base) tony3@Tonys-MacBook-Pro mlops % dvc init

An import error as follows occurs:

from fsspec.asyn import fsspec_loop
ImportError: cannot import name 'fsspec_loop' from 'fsspec.asyn'

I try the following:

  1. Go to the file location /venv/lib/python3.7/site-packages/fsspec/asyn.py and inspect the file asyn.py. Find that there is no function with the name "fsspec_loop".

  2. Try to upgrade the dvc to a newer version by,

pip install dvc --upgrade

But the dvc version remains the same (2.10.2).

  1. Uninstall dvc by,
pip uninstall dvc

and try to install the newest version,

pip install dvc==2.42.0

The response shows that the latest version of dvc that is compatible with Python 3.7.13 is 2.10.2. As a result, version 2.42.0 cannot be installed.

  1. Try to install dvc using brew. But the dvc is installed in a location outside the venv (at /usr/local/bin, where a later version of Python is used).
(venv) (base) tony3@Tonys-MacBook-Pro mlops % brew install dvc
(venv) (base) tony3@Tonys-MacBook-Pro mlops % dvc --version
2.41.1
(venv) (base) tony3@Tonys-MacBook-Pro mlops % which dvc
/usr/local/bin/dvc

The entire traceback (most recent call last) is as follows,

traceback

3

There are 3 best solutions below

1
On BEST ANSWER

Thanks to the comment by @ruslankuprieiev.

dvc version 2.10.2 is successfully installed and initialized in the venv with Python 3.7.13 after downgrading fsspec to version 2022.11.0 .

The following are the steps.

  1. Install dvc version 2.10.2,
  2. Check which dvc is used (the one in venv),
  3. Check fsspec version number (== 2023.1.0),
  4. Force reinstall to downgrade fsspec to 2022.11.0,
  5. Check fsspec version number again (== 2022.11.0), and
  6. Force initialize dvc since there is an existing .dvc folder in the project directory.

The code is as follows,

(venv) (base) tony3@Tonys-MacBook-Pro mlops % pip install dvc==2.10.2
(venv) (base) tony3@Tonys-MacBook-Pro mlops % which dvc
/PathtoFile/venv/bin/dvc
(venv) (base) tony3@Tonys-MacBook-Pro mlops % pip show fsspec
Name: fsspec
Version: 2023.1.0
...
(venv) (base) tony3@Tonys-MacBook-Pro mlops % pip install --force-reinstall -v "fsspec==2022.11.0"
(venv) (base) tony3@Tonys-MacBook-Pro mlops % pip show fsspec
Name: fsspec
Version: 2022.11.0
...
(venv) (base) tony3@Tonys-MacBook-Pro mlops % dvc init -f
2
On

I experienced the same problem and solved it by installing an older version "fsspec". (my python is 3.8 and dvc 2.8.3)

pip uninstall fsspec
pip install fsspec==2022.7.1
0
On

Use the below conda command, this worked like charm for me.

conda install -c conda-forge fsspec