no module named transformers.cache_utils

#9
by gpucce - opened

trying to run from_pretrained copying from the readme I get this error

no module named transformers.cache_utils

I tried transformers 4.34, 4.35 and 4.36-dev0 but they all shoe the same error, do you maybe know why I get it?

Thank you!

Because you have the transformers version of pip and not huggingface. You have to do both command :
pip uninstall -y transformers
pip install git+https://github.com/huggingface/transformers

Thank you!

would this be the same as installing from source after pulling?

git clone https://github.com/huggingface/transformers
cd transformers
pip install -e .

?

My command downloads and installs directly from the GitHub repository without the need for manual cloning. It is a quick way to install a package from a Git repository.

The commands git clone https://github.com/huggingface/transformers, followed by cd transformers and pip install -e ., involve cloning the repository locally and then installing the package in editable mode. Using editable mode allows immediate reflection of code changes made in the local directory in the virtual environment without requiring a reinstall.

Both can be used to install the same package, but mine is more concise, while yours provides flexibility if you plan to work on the package's source code.

Because you have the transformers version of pip and not huggingface. You have to do both command :
pip uninstall -y transformers
pip install git+https://github.com/huggingface/transformers

do you know by any chance huggingface would make the experience the same in the pip repository? it is bad for users, they should update the repository in pip as well

This solution did not work for me, same error, please advise, thank you!

Because you have the transformers version of pip and not huggingface. You have to do both command :
pip uninstall -y transformers
pip install git+https://github.com/huggingface/transformers

do you know by any chance huggingface would make the experience the same in the pip repository? it is bad for users, they should update the repository in pip as well

They haven't shared any information on this but several updates have taken place recently so we can only hope that this is the case now.

This solution did not work for me, same error, please advise, thank you!

Did you try with the version of pip transformers too ?

Get Successfully installed transformers-4.38.0.dev0 via git but still stuck at

  File "/home/katopz/.cache/huggingface/modules/transformers_modules/openbmb/MiniCPM-2B-dpo-fp16/e7a50289e4f839674cf8d4a5a2ce032ccacf64ac/modeling_minicpm.py", line 32, in <module>
    from transformers.cache_utils import Cache, DynamicCache
ModuleNotFoundError: No module named 'transformers.cache_utils'

Any hint?

Get Successfully installed transformers-4.38.0.dev0 via git but still stuck at

  File "/home/katopz/.cache/huggingface/modules/transformers_modules/openbmb/MiniCPM-2B-dpo-fp16/e7a50289e4f839674cf8d4a5a2ce032ccacf64ac/modeling_minicpm.py", line 32, in <module>
    from transformers.cache_utils import Cache, DynamicCache
ModuleNotFoundError: No module named 'transformers.cache_utils'

Any hint?

Use this :
pip uninstall -y transformers
pip install git+https://github.com/huggingface/transformers

What if in the end I decided to reverse back to the old one?

The npm one you mean? Well it might crash unless npm uses the one from huggingface now but I doubt it...

Sign up or log in to comment