Attribute Error in Django,when using IMDbpy

306 Views Asked by At

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!

1

There are 1 best solutions below

1
On

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