Skip to content

[Bug]: ImportError: cannot import name 'download' from 'aistudio_sdk.hub' #11133

@openvino-book

Description

@openvino-book

软件环境

- paddlepaddle:
(build_llm) ppov@paddle:~$ pip list | grep paddle
paddle2onnx              2.0.1
paddlefsl                1.1.0
paddlenlp                2.8.1
paddlepaddle-gpu         3.2.0

重复问题

  • I have searched the existing issues

错误描述

---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
Cell In[8], line 3
      1 import time
      2 import random
----> 3 from paddlenlp.metrics import BLEU
      4 from tqdm import tqdm
      6 # ==============================================
      7 # 🧩 Step 1: 准备训练组件
      8 # ==============================================

File ~/miniconda3/envs/build_llm/lib/python3.11/site-packages/paddlenlp/__init__.py:35
     28     logger.warning(
     29         "Detected that datasets module was imported before paddlenlp. "
     30         "This may cause PaddleNLP datasets to be unavalible in intranet. "
     31         "Please import paddlenlp before datasets module to avoid download issues"
     32     )
     33 import paddle
---> 35 from . import (
     36     data,
     37     dataaug,
     38     datasets,
     39     embeddings,
     40     experimental,
     41     layers,
     42     losses,
     43     metrics,
     44     ops,
     45     peft,
     46     prompt,
     47     quantization,
     48     seq2vec,
     49     trainer,
     50     transformers,
     51     utils,
     52     version,
     53 )
     54 from .server import SimpleServer
     55 from .taskflow import Taskflow

File ~/miniconda3/envs/build_llm/lib/python3.11/site-packages/paddlenlp/data/__init__.py:18
     16 from .causal_dataset import *
     17 from .collate import *
---> 18 from .data_collator import *
     19 from .dist_dataloader import *
     20 from .sampler import *

File ~/miniconda3/envs/build_llm/lib/python3.11/site-packages/paddlenlp/data/data_collator.py:26
     23 import numpy as np
     24 import paddle
---> 26 from ..transformers import BertTokenizer
     27 from ..transformers.tokenizer_utils_base import (
     28     BatchEncoding,
     29     PaddingStrategy,
     30     PretrainedTokenizerBase,
     31 )
     33 __all__ = [
     34     "DataCollatorWithPadding",
     35     "default_data_collator",
   (...)     41     "DataCollatorForWholeWordMask",
     42 ]

File ~/miniconda3/envs/build_llm/lib/python3.11/site-packages/paddlenlp/transformers/__init__.py:17
      1 # Copyright (c) 2023 PaddlePaddle Authors. All Rights Reserved.
      2 #
      3 # Licensed under the Apache License, Version 2.0 (the "License");
   (...)     12 # See the License for the specific language governing permissions and
     13 # limitations under the License.
     16 from .configuration_utils import PretrainedConfig
---> 17 from .model_utils import PretrainedModel, register_base_model
     18 from .tokenizer_utils import (
     19     PretrainedTokenizer,
     20     BPETokenizer,
   (...)     26     convert_to_unicode,
     27 )
     28 from .processing_utils import ProcessorMixin

File ~/miniconda3/envs/build_llm/lib/python3.11/site-packages/paddlenlp/transformers/model_utils.py:66
     54 from paddlenlp.utils.env import (
     55     CONFIG_NAME,
     56     LEGACY_CONFIG_NAME,
   (...)     62     SAFE_WEIGHTS_NAME,
     63 )
     64 from paddlenlp.utils.log import logger
---> 66 from ..generation import GenerationConfig, GenerationMixin
     67 from ..utils import device_guard
     68 from ..utils.download import resolve_file_path

File ~/miniconda3/envs/build_llm/lib/python3.11/site-packages/paddlenlp/generation/__init__.py:33
     15 from .logits_process import (
     16     ForcedBOSTokenLogitsProcessor,
     17     ForcedEOSTokenLogitsProcessor,
   (...)     24     TopPProcess,
     25 )
     26 from .stopping_criteria import (
     27     MaxLengthCriteria,
     28     MaxTimeCriteria,
   (...)     31     validate_stopping_criteria,
     32 )
---> 33 from .streamers import BaseStreamer, TextIteratorStreamer, TextStreamer
     34 from .utils import BeamSearchScorer, GenerationMixin, get_unfinished_flag

File ~/miniconda3/envs/build_llm/lib/python3.11/site-packages/paddlenlp/generation/streamers.py:18
     15 from queue import Queue
     16 from typing import Optional
---> 18 from paddlenlp.transformers.tokenizer_utils import PretrainedTokenizer
     21 class BaseStreamer:
     22     """
     23     Base class from which `.generate()` streamers should inherit.
     24     """

File ~/miniconda3/envs/build_llm/lib/python3.11/site-packages/paddlenlp/transformers/tokenizer_utils.py:61
     46 from ..data.vocab import Vocab
     47 from .tokenizer_utils_base import (
     48     AddedToken,
     49     BatchEncoding,
   (...)     59     TruncationStrategy,
     60 )
---> 61 from .utils import InitTrackerMeta, fn_args_to_dict
     63 __all__ = [
     64     "PretrainedTokenizer",
     65     "BPETokenizer",
   (...)     70     "convert_to_unicode",
     71 ]
     74 def convert_to_unicode(text):

File ~/miniconda3/envs/build_llm/lib/python3.11/site-packages/paddlenlp/transformers/utils.py:59
     56 from paddlenlp.utils.log import logger
     58 from ..utils.download import resolve_file_path
---> 59 from .aistudio_utils import aistudio_download
     61 HUGGINGFACE_CO_RESOLVE_ENDPOINT = "https://huggingface.co"
     64 def convert_ndarray_dtype(np_array: np.ndarray, target_dtype: str) -> np.ndarray:

File ~/miniconda3/envs/build_llm/lib/python3.11/site-packages/paddlenlp/transformers/aistudio_utils.py:17
      1 # Copyright (c) 2023 PaddlePaddle Authors. All Rights Reserved.
      2 #
      3 # Licensed under the Apache License, Version 2.0 (the "License");
   (...)     12 # See the License for the specific language governing permissions and
     13 # limitations under the License.
     15 from typing import Optional
---> 17 from aistudio_sdk.hub import download
     20 class UnauthorizedError(Exception):
     21     pass

ImportError: cannot import name 'download' from 'aistudio_sdk.hub' (/home/ppov/miniconda3/envs/build_llm/lib/python3.11/site-packages/aistudio_sdk/hub.py)

稳定复现步骤 & 代码

(build_llm) ppov@paddle:~$ python -c "from paddlenlp.metrics import BLEU"

/home/ppov/miniconda3/envs/build_llm/lib/python3.11/site-packages/_distutils_hack/init.py:30: UserWarning: Setuptools is replacing distutils. Support for replacing an already imported distutils is deprecated. In the future, this condition will fail. Register concerns at https://github.com/pypa/setuptools/issues/new?template=distutils-deprecation.yml
warnings.warn(
Traceback (most recent call last):
File "", line 1, in
File "/home/ppov/miniconda3/envs/build_llm/lib/python3.11/site-packages/paddlenlp/init.py", line 35, in
from . import (
File "/home/ppov/miniconda3/envs/build_llm/lib/python3.11/site-packages/paddlenlp/data/init.py", line 18, in
from .data_collator import *
File "/home/ppov/miniconda3/envs/build_llm/lib/python3.11/site-packages/paddlenlp/data/data_collator.py", line 26, in
from ..transformers import BertTokenizer
File "/home/ppov/miniconda3/envs/build_llm/lib/python3.11/site-packages/paddlenlp/transformers/init.py", line 17, in
from .model_utils import PretrainedModel, register_base_model
File "/home/ppov/miniconda3/envs/build_llm/lib/python3.11/site-packages/paddlenlp/transformers/model_utils.py", line 66, in
from ..generation import GenerationConfig, GenerationMixin
File "/home/ppov/miniconda3/envs/build_llm/lib/python3.11/site-packages/paddlenlp/generation/init.py", line 33, in
from .streamers import BaseStreamer, TextIteratorStreamer, TextStreamer
File "/home/ppov/miniconda3/envs/build_llm/lib/python3.11/site-packages/paddlenlp/generation/streamers.py", line 18, in
from paddlenlp.transformers.tokenizer_utils import PretrainedTokenizer
File "/home/ppov/miniconda3/envs/build_llm/lib/python3.11/site-packages/paddlenlp/transformers/tokenizer_utils.py", line 61, in
from .utils import InitTrackerMeta, fn_args_to_dict
File "/home/ppov/miniconda3/envs/build_llm/lib/python3.11/site-packages/paddlenlp/transformers/utils.py", line 59, in
from .aistudio_utils import aistudio_download
File "/home/ppov/miniconda3/envs/build_llm/lib/python3.11/site-packages/paddlenlp/transformers/aistudio_utils.py", line 17, in
from aistudio_sdk.hub import download
ImportError: cannot import name 'download' from 'aistudio_sdk.hub' (/home/ppov/miniconda3/envs/build_llm/lib/python3.11/site-packages/aistudio_sdk/hub.py)

Metadata

Metadata

Assignees

Labels

bugSomething isn't workingstale

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions