transformers
transformers copied to clipboard
Cannot import pipelines from transformers
Hi, I use a Windows 10 Proffessional laptop for development and am using python 3.7.6 conda virtual env. I get the following run time error when running my code (below, after the error details).
<<
bertqa interactive window [PTVS 17.0.22089.1-17.0]
Type $help for a list of commands.
The interactive window has not yet started.
Running D:\Projects2017\bertqa\bertqa\aaa_scratch.py
Traceback (most recent call last):
File "d:\python\Anaconda3\envs\transformers_qa\lib\site-packages\transformers\utils\import_utils.py", line 905, in get_module
return importlib.import_module("." + module_name, self.name)
File "d:\python\Anaconda3\envs\transformers_qa\lib\importlib_init.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "D:\Projects2017\bertqa\bertqa\aaa_scratch.py", line 5, in
The following is the code I am trying to execute: << #imports import os, sys import pandas as PD import numpy as NP from transformers import AutoModelForQuestionAnswering, AutoTokenizer, pipelines
_text = 'I bought a Toyota Corala last January. It works well..' _questions = [ 'What did the person buy?', 'What is working?', 'When did he buy?', ]
_model_name = "deepset/tinyroberta-squad2"
def main(): '''Main entry point''' nlp = pipeline('question-answering', model=model_name, tokenizer=model_name) qa_input = {} qa_input['question'] = _questions[0] qa_input['context'] = _text
answer = nlp(QA_input) print(answer)
''' Required for all python programs. ''' if name == 'main': print('Starting the QA tool.') main() print('Done')
I will appreciate if you let me know how to overcome this issue. Awaiting your reply.
Hi @balachander1964 -- if you check the error log you shared, the error does not come from the transformers library. From a quick google search, the error seems to be from the environment set up (try googling DLL load failed: The specified module could not be found.)
As per our issues guidelines, we reserve GitHub issues for bugs in the repository and/or feature requests. For any other matters, we'd like to invite you to use our forum 🤗
This issue has been automatically marked as stale because it has not had recent activity. If you think this still needs to be addressed please comment on this thread.
Please note that issues that do not follow the contributing guidelines are likely to be ignored.