Import error of ImportError of 'Qwen2_5_VLForConditionalGeneration' from transformers library

#17
by akbarmq01 - opened

Hi all,
I tried to install transformer package by pulling it from github and building it. its giving following error:
ImportError: cannot import name 'Qwen2_5_VLForConditionalGeneration' from 'transformers'. Can you please help?

Qwen2_5_VLForConditionalGeneration isn't in the most recent release (4.48.3). Instead, you need to install transformers directly from source until the next release: pip install git+https://github.com/huggingface/transformers.git

I am trying to build from source and transformers is not installing. Please help me resolve this issue. I am getting the following error:

kaveri@gnode008:~/LO$ python -m pip install git+https://github.com/huggingface/transformers
Collecting git+https://github.com/huggingface/transformers
  Cloning https://github.com/huggingface/transformers to /tmp/pip-req-build-bamqqjcc
  Running command git clone --filter=blob:none --quiet https://github.com/huggingface/transformers /tmp/pip-req-build-bamqqjcc
  Resolved https://github.com/huggingface/transformers to commit 2b8a15cc3f1a0c94cf817a8fd8c87bca28737e09
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Preparing metadata (pyproject.toml) ... done
Requirement already satisfied: filelock in /home2/kaveri/miniconda3/envs/intent/lib/python3.8/site-packages (from transformers==4.51.0.dev0) (3.16.1)
Requirement already satisfied: huggingface-hub<1.0,>=0.26.0 in /home2/kaveri/miniconda3/envs/intent/lib/python3.8/site-packages (from transformers==4.51.0.dev0) (0.29.3)
Requirement already satisfied: numpy>=1.17 in /home2/kaveri/miniconda3/envs/intent/lib/python3.8/site-packages (from transformers==4.51.0.dev0) (1.24.4)
Requirement already satisfied: packaging>=20.0 in /home2/kaveri/miniconda3/envs/intent/lib/python3.8/site-packages (from transformers==4.51.0.dev0) (24.2)
Requirement already satisfied: pyyaml>=5.1 in /home2/kaveri/miniconda3/envs/intent/lib/python3.8/site-packages (from transformers==4.51.0.dev0) (6.0.2)
Requirement already satisfied: regex!=2019.12.17 in /home2/kaveri/miniconda3/envs/intent/lib/python3.8/site-packages (from transformers==4.51.0.dev0) (2024.11.6)
Requirement already satisfied: requests in /home2/kaveri/miniconda3/envs/intent/lib/python3.8/site-packages (from transformers==4.51.0.dev0) (2.32.3)
Collecting tokenizers<0.22,>=0.21 (from transformers==4.51.0.dev0)
  Using cached tokenizers-0.21.0.tar.gz (343 kB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Preparing metadata (pyproject.toml) ... error
  error: subprocess-exited-with-error
  
  × Preparing metadata (pyproject.toml) did not run successfully.
  │ exit code: 1
  ╰─> [19 lines of output]
      Checking for Rust toolchain....
      Traceback (most recent call last):
        File "/home2/kaveri/miniconda3/envs/intent/lib/python3.8/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 389, in <module>
          main()
        File "/home2/kaveri/miniconda3/envs/intent/lib/python3.8/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 373, in main
          json_out["return_val"] = hook(**hook_input["kwargs"])
        File "/home2/kaveri/miniconda3/envs/intent/lib/python3.8/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 175, in prepare_metadata_for_build_wheel
          return hook(metadata_directory, config_settings)
        File "/tmp/pip-build-env-zfr6elsv/overlay/lib/python3.8/site-packages/maturin/__init__.py", line 171, in prepare_metadata_for_build_wheel
          output = subprocess.check_output(["cargo", "--version"]).decode("utf-8", "ignore")
        File "/home2/kaveri/miniconda3/envs/intent/lib/python3.8/subprocess.py", line 415, in check_output
          return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
        File "/home2/kaveri/miniconda3/envs/intent/lib/python3.8/subprocess.py", line 493, in run
          with Popen(*popenargs, **kwargs) as process:
        File "/home2/kaveri/miniconda3/envs/intent/lib/python3.8/subprocess.py", line 858, in __init__
          self._execute_child(args, executable, preexec_fn, close_fds,
        File "/home2/kaveri/miniconda3/envs/intent/lib/python3.8/subprocess.py", line 1720, in _execute_child
          raise child_exception_type(errno_num, err_msg, err_filename)
      NotADirectoryError: [Errno 20] Not a directory: 'cargo'
      [end of output]
  
  note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed

× Encountered error while generating package metadata.
╰─> See above for output.

note: This is an issue with the package mentioned above, not pip.
hint: See above for details.

Qwen2_5_VLForConditionalGeneration isn't in the most recent release (4.48.3). Instead, you need to install transformers directly from source until the next release: pip install git+https://github.com/huggingface/transformers.git

Same error when installing the newest transformers.

Qwen2_5_VLForConditionalGeneration isn't in the most recent release (4.48.3). Instead, you need to install transformers directly from source until the next release: pip install git+https://github.com/huggingface/transformers.git

Same error when installing the newest transformers.

same goes for me.

akbarmq01 changed discussion status to closed

The version of transformers 4.54.0.dev0 raise the exact error. Can anyone solve it?

Same error for me also.

$ python qwen_single_7b.py 
/projects/data/vision-team/hrithik_sagar/BoundingDocs/.qwen_env/lib/python3.11/site-packages/transformers/utils/hub.py:111: FutureWarning: Using `TRANSFORMERS_CACHE` is deprecated and will be removed in v5 of Transformers. Use `HF_HOME` instead.
  warnings.warn(
Traceback (most recent call last):
  File "/projects/data/vision-team/hrithik_sagar/BoundingDocs/repo/BoundingDocs_Dataset_Conversion/models_exp/qwen/qwen_single_7b.py", line 33, in <module>
    from transformers.models.qwen2_5_vl.modeling_qwen2_5_vl import Qwen2_5_VLForCausalLM
ImportError: cannot import name 'Qwen2_5_VLForCausalLM' from 'transformers.models.qwen2_5_vl.modeling_qwen2_5_vl' (/projects/data/vision-team/hrithik_sagar/BoundingDocs/.qwen_env/lib/python3.11/site-packages/transformers/models/qwen2_5_vl/modeling_qwen2_5_vl.py)
$ pip show transformers
Name: transformers
Version: 4.54.1
Summary: State-of-the-art Machine Learning for JAX, PyTorch and TensorFlow
Home-page: https://github.com/huggingface/transformers
Author: The Hugging Face team (past and future) with the help of all our contributors (https://github.com/huggingface/transformers/graphs/contributors)
Author-email: [email protected]
License: Apache 2.0 License
Location: /projects/data/vision-team/hrithik_sagar/BoundingDocs/.qwen_env/lib/python3.11/site-packages
Requires: filelock, huggingface-hub, numpy, packaging, pyyaml, regex, requests, safetensors, tokenizers, tqdm
Required-by: 

具体执行命令如下,已解决
pip uninstall transformers
pip install git+https://github.com/huggingface/[email protected]

Sign up or log in to comment