ModuleNotFoundError: No module named 'transformers.utils'
VS CODEI am trying to run code that uses BlipProcessor, BlipForConditionalGeneration however whenever I run it The following is outputted:[Running] python -u “c:\Users\joshu\Desktop\AI_project.venv\first.py”Traceback (most recent call last):File “c:\Users\joshu\Desktop\AI_project.venv\first.py”, line 3, infrom transformers import BlipProcessor, BlipForConditionalGenerationFile “C:\Users\joshu\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\transformers_init_.py”, line 26, infrom . import dependency_versions_checkFile “C:\Users\joshu\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\transformers\dependency_versions_check.py”, line 16, infrom .utils.versions import require_version, require_version_coreModuleNotFoundError: No module named ‘transformers.utils’[Done] exited with code=1 in 1.077 secondsI have installed pip and the transformers using pip install transformers. I have tried then installing the transformers through the git link I have tried updating the transformers and the code still doesn’t run. Is there any solutions?
2024-08-23T08:35:14Z
hi@LFEsDungeonCan you please run these and share the output:pip freeze
python -c "import transformers.utils.versions"To reinstall the transformers, you can run the following:pip install --force-reinstall "transformers"
2024-08-24T22:51:23Z
The output to the pip freeze command was:(.venv) PSC:\Users\joshu\Desktop\AI_project> pip freezeabsl-py==2.1.0aiofiles==23.2.1aiohappyeyeballs==2.4.0aiohttp==3.10.5aiosignal==1.3.1altair==5.4.0annotated-types==0.7.0anyio==4.4.0attrs==24.2.0blinker==1.8.2cachetools==5.5.0certifi==2024.7.4charset-normalizer==3.3.2click==8.1.7colorama==0.4.6contourpy==1.2.1cycler==0.12.1datasets==2.21.0dill==0.3.8docker-pycreds==0.4.0fastapi==0.112.1ffmpy==0.4.0filelock==3.15.4fonttools==4.53.1frozenlist==1.4.1fsspec==2024.6.1gitdb==4.0.11GitPython==3.1.43gradio==4.42.0gradio_client==1.3.0grpcio==1.65.5h11==0.14.0httpcore==1.0.5httpx==0.27.0huggingface-hub==0.24.6idna==3.8importlib_resources==6.4.4Jinja2==3.1.4joblib==1.4.2jsonschema==4.23.0jsonschema-specifications==2023.12.1kiwisolver==1.4.5Markdown==3.7markdown-it-py==3.0.0MarkupSafe==2.1.5matplotlib==3.9.2mdurl==0.1.2mpmath==1.3.0multidict==6.0.5multiprocess==0.70.16narwhals==1.5.2networkx==3.3numpy==2.1.0orjson==3.10.7packaging==24.1pandas==2.2.2pillow==10.4.0platformdirs==4.2.2protobuf==5.27.3psutil==6.0.0pyarrow==17.0.0pydantic==2.8.2pydantic_core==2.20.1pydeck==0.9.1pydub==0.25.1Pygments==2.18.0pyparsing==3.1.2python-dateutil==2.9.0.post0python-multipart==0.0.9pytz==2024.1PyYAML==6.0.2referencing==0.35.1regex==2024.7.24requests==2.32.3rich==13.7.1rpds-py==0.20.0ruff==0.6.2safetensors==0.4.4scikit-learn==1.5.1scipy==1.14.1semantic-version==2.10.0sentencepiece==0.2.0sentry-sdk==2.13.0seqeval==1.2.2setproctitle==1.3.3setuptools==73.0.1shellingham==1.5.4simpletransformers==0.70.1six==1.16.0smmap==5.0.1sniffio==1.3.1starlette==0.38.2streamlit==1.37.1sympy==1.13.2tenacity==8.5.0tensorboard==2.17.1tensorboard-data-server==0.7.2tensorboardX==2.6.2.2threadpoolctl==3.5.0tokenizers==0.19.1toml==0.10.2tomlkit==0.12.0torch==2.4.0torchaudio==2.4.0torchvision==0.19.0tornado==6.4.1tqdm==4.66.5typer==0.12.4typing_extensions==4.12.2tzdata==2024.1urllib3==2.2.2uvicorn==0.30.6wandb==0.17.7watchdog==4.0.2websockets==12.0Werkzeug==3.0.4xxhash==3.5.0yarl==1.9.4The output to the python -c “import transformers.utils.versions” command was:(.venv) PS C:\Users\joshu\Desktop\AI_project> python -c “import transformers.utils.versions”Traceback (most recent call last):File “”, line 1, inFile “C:\Users\joshu\Desktop\AI_project.venv\Lib\site-packages\transformers_init_.py”, line 26, infrom . import dependency_versions_checkFile “C:\Users\joshu\Desktop\AI_project.venv\Lib\site-packages\transformers\dependency_versions_check.py”, line 16, infrom .utils.versions import require_version, require_version_coreFile “C:\Users\joshu\Desktop\AI_project.venv\Lib\site-packages\transformers\utils_init_.py”, line 34, infrom .generic import (File “C:\Users\joshu\Desktop\AI_project.venv\Lib\site-packages\transformers\utils\generic.py”, line 462, inimport torch.utils._pytree astorch_pytreeFile "C:\Users\joshu\Desktop\AI_project.venv\Lib\site-packages\torch_init.py", line 148, inraise errOSError: [WinError 126] The specified module could not be found. Error loading “C:\Users\joshu\Desktop\AI_project.venv\Lib\site-packages\torch\lib\fbgemm.dll” or one of its dependencies.I also tried to reinstalled transformers and the output was the same . IT did come up with an error that said:ERROR: pip’s dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts.torchvision 0.19.0 requires numpy<2, but you have numpy 2.1.0 which is incompatible.Thanks for taking the time out of your day to help me.
2024-08-25T20:11:50Z
hiIf possible, can you please create a new virtual environment and runpython.exe -m pip install --upgrade pipbefore installing transformers?
2024-08-27T17:28:51Z
I attempted this solution as well and had no luck. The same error message:[Running] python -u “c:\Users\joshu\Desktop\AI_project.venv\first.py”Traceback (most recent call last):File “c:\Users\joshu\Desktop\AI_project.venv\first.py”, line 3, infrom transformers import BlipProcessor, BlipForConditionalGenerationFile “C:\Users\joshu\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\transformers_init_.py”, line 26, infrom . import dependency_versions_checkFile “C:\Users\joshu\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.11_qbz5n2kfra8p0\LocalCache\local-packages\Python311\site-packages\transformers\dependency_versions_check.py”, line 16, infrom .utils.versions import require_version, require_version_coreModuleNotFoundError: No module named ‘transformers.utils’was output
2024-09-09T10:17:52Z
Hi! I recently had this exact error, I had to enable long paths on windows to allow the transformers package to be correctly installed. Follow this guide here:Maximum Path Length Limitation - Win32 apps | Microsoft LearnFrom the link: Computer Configuration > Administrative Templates > System > Filesystem > Enable Win32 long paths > Apply and click OK