Viswamber Prasad
Viswamber Prasad

Reputation: 81

Attribute Error in Django,when using IMDbpy

I am trying to use the IMDbpy library in my django projects,but it raises an Attribute Error. I tried all the solutions available on the internet,but none seem to work,could you please help me with this? The Error:

moviesDB = imdb.IMDb()
AttributeError: module 'imdb' has no attribute 'IMDb' 

The code:

import imdb

moviesDB = imdb.IMDb()

movies= moviesDB.search_movie('whatever_movie')
id = movies[0].getID()
movie = moviesDB.get_movie(id)

print(movie)

title=movie['title']
rating = movie['rating']
cover=movie['cover url']
print(title,rating,cover)

I have been scratching my head the entire day,due to this error,I'm kinda new to this,so please help! I tried reinstalling the imdbpy library,pip3 installed it,renamed it but nothing seems to be working. The code is working in external files,but in the views.py in django,it just doesnt seem to work please help!

Upvotes: 0

Views: 329

Answers (1)

kermit_1313
kermit_1313

Reputation: 11

Try from imdb import IMDb then use IMDb() to initialize

Upvotes: 1

Related Questions