8

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

Tony Peng
  • 579
  • 5
  • 10
  • 4
    last fsspec version deleted fsspec_loop and newer adlfs version has that handled as well. Please check that `pip check` doesn't point out any errors and try downgrading fsspec version to 2022.11.0. Also note that 3.7 support was dropped last year, and dvc supports 3.8+. – Ruslan Kuprieiev Jan 21 '23 at 21:34

2 Answers2

12

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
Tony Peng
  • 579
  • 5
  • 10
  • 2
    i would suggest upgrading to python 3.8+ too, 3.7 will reach EOL this summer, a lot of tools are dropping it already. Also dvc 2.10.2 is very old, so you are missing out on some fixes and optimizations in the latest versions. – Ruslan Kuprieiev Jan 21 '23 at 23:50
3

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
Leonardo
  • 120
  • 9
  • I did the same with mamba (I installed dvc with mamba). So the whole installation process for me was as follows `conda install -c conda-forge mamba` `mamba install -c conda-forge dvc` `mamba install -c conda-forge fsspec==2022.7.1` My python is 3.7.4 and I have Ubuntu 20.04 – antortjim Feb 20 '23 at 21:56
  • 1
    Actually, as of today Feb 20 2023, support is only available from Python 3.8+ (from the docs), and indeed, with this installation I cannot `dvc push` to Google Drive. So I just created a new env with Python 3.8 and now it's fine – antortjim Feb 20 '23 at 22:27