0

在安装 Anaconda 并激活它后,在 Colab 环境中使用 pytorch_transformers 时遇到此错误。我在https://github.com/huggingface/transformers/issues/1705中发现了一个类似的问题,但它对我不起作用。谢谢你的帮助!

!pip install transformers
!pip install simpletransformers
!pip install pytorch-transformers

import os
os.environ['PYTHONPATH'] = "/usr/local/bin/python"

import sys!source activate transformers!source activate transformers
sys.path.append('/usr/local/lib/python3.6/site-packages/')

!conda --version
!conda update -n base conda
!conda install -q -y --prefix /usr/local -c conda-forge tqdm
!conda create -n transformers tqdm
!source activate transformers

from __future__ import absolute_import, division, print_function

import glob
import logging
import os
import random
import json

import numpy as np
import torch
from torch.utils.data import (DataLoader, RandomSampler, SequentialSampler,
                              TensorDataset)
import random
from torch.utils.data.distributed import DistributedSampler
from tqdm import tqdm_notebook, trange

from pytorch_transformers import (WEIGHTS_NAME, BertConfig, BertForSequenceClassification, BertTokenizer,
                                  XLMConfig, XLMForSequenceClassification, XLMTokenizer, 
                                  XLNetConfig, XLNetForSequenceClassification, XLNetTokenizer,
                                  RobertaConfig, RobertaForSequenceClassification, RobertaTokenizer)

from pytorch_transformers import AdamW, WarmupLinearSchedule

from utils import (convert_examples_to_features,
                        output_modes, processors)

logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(__name__)

     22 from pytorch_transformers import AdamW, WarmupLinearSchedule
     23 
---> 24 from utils import (convert_examples_to_features,
     25                         output_modes, processors)
     26 

ModuleNotFoundError: No module named 'utils'
4

0 回答 0