transformers 패키지가 설치가 안됩니다.

2021.08.04 10:05 8,848 조회

!pip install konlpy


!pip install transformers


!pip3 install tensorflow_text>=2.0.0rc0


!python -c "from transformers import pipeline; print(pipeline('sentiment-analysis')('I hate you'))"


import pandas as pd

import numpy as np

import matplotlib.pyplot as plt

import re

import json

import os

import tqdm


from konlpy.tag import Okt


import sklearn

from sklearn.preprocessing import LabelEncoder


from sklearn.metrics import log_loss, accuracy_score,f1_score

import tensorflow as tf

from tensorflow.keras.preprocessing.sequence import pad_sequences

from tensorflow.keras.preprocessing.text import Tokenizer

from tensorflow.keras.callbacks import EarlyStopping, ModelCheckpoint

from transformers import *

---------------------------------------------------------------------------
ModuleNotFoundError                       Traceback (most recent call last)
<ipython-input-3-8f9ac06b3db7> in <module>()
     17 from tensorflow.keras.preprocessing.text import Tokenizer
     18 from tensorflow.keras.callbacks import EarlyStopping, ModelCheckpoint
---> 19 from transformers import *



5 frames


/usr/local/lib/python3.7/dist-packages/transformers/models/xlnet/tokenization_xlnet.py in <module>()
     21 from typing import Any, Dict, List, Optional, Tuple
     22 
---> 23 import sentencepiece as spm
     24 
     25 from ...file_utils import SPIECE_UNDERLINE

ModuleNotFoundError: No module named 'sentencepiece'


패키지 설치를 했지만 패키지 내의 존재하지 않는 모듈이 있다고 나옵니다. 이러는 원인도 모르겠고 해결 방법이 구글링해도 나오질 않습니다. 혹시 도움을 주실 수 있을까요?

로그인이 필요합니다
0 / 1000
datu
2021.08.04 11:52

sentencepiece라는 모듈이 설치가 되지 않은 것 같습니다.
!pip install sentencepiece를 해보시는 건 어떨까요?

OmegaSam
2021.08.04 12:25

감사합니다! 그런데 왜 저런 일이 발생하는지 모르겠네요. transformers를 설치하면 전부 설치되는게 맞지 않나요?

datu
2021.08.04 13:30

저도 겪어본 일이라서 잘 알고 있습니다 ㅎㅎ transformers 버전 문제라고 추측하고 있습니다!

DimensionSTP
2021.08.05 09:55

transformers==3.3.0으로 설치시 문제없이 됩니다 저도 같은 문제 겪었습니다