wordnik / wordnik-python3

wordnik python3 library
74 stars 13 forks source link

NameError: name 'swagger' is not defined #2

Closed Joozty closed 6 years ago

Joozty commented 7 years ago

I recently download wornik package using pip without any errors.

I ran this code:

from wordnik import *

apiUrl = 'http://api.wordnik.com/v4'
apiKey = '********************************************'

client = swagger.ApiClient(apiKey, apiUrl)
wordApi = WordApi.WordApi(client)
definitions = wordApi.getDefinitions('badger',
                                     partOfSpeech='verb',
                                     sourceDictionaries='wiktionary',
                                     limit=1)
print definitions[0].text

It gives me error: client = swagger.ApiClient(apiKey, apiUrl) NameError: name 'swagger' is not defined

Where can be a problem?

Thanks for help

50kawa commented 6 years ago

in my case, I checked where the interpreter loaded wordnik by

import wordnik print(wordnik.file)

and I find that the interpreter loaded wordnik from wordnik.py that was made by myself. so, I delete it and can run my code correctly.