Joseph Song
Joseph Song

Reputation: 194

Cannot import Flask-Paginate

I installed Flask-Paginate using pip, but when I try to import it I get ImportError: cannot import name 'Paginate'. How do I import this?

$ pip install -U flask-paginate
>>> from flask import Paginate
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: cannot import name 'Paginate'

The package also isn't recognized in PyCharm.

Upvotes: 0

Views: 2553

Answers (3)

Michal Nešpůrek
Michal Nešpůrek

Reputation: 1

if anything above works use in VSCode it helps:

py -m pip install Flask-Paginate

Upvotes: 0

Andrejs Cainikovs
Andrejs Cainikovs

Reputation: 28434

As mentioned in flask-paginate docs:

from flask.ext.paginate import Pagination

However, flask.ext is removed. Use this instead:

from flask_paginate import Pagination

Upvotes: 0

davidism
davidism

Reputation: 127190

Don't import it from flask, it's not part of Flask. Import it from flask_paginate, the module you installed. It's also called Pagination.

The docs show how to import it (although they are using the deprecated flask.ext notation).

from flask_paginate import Pagination

Configure the project interpreter in PyCharm to point to the virtualenv you installed the package to.

Upvotes: 4

Related Questions