Importerror: Cannot Import Name X

ImportError: cannot import name 'x' from 'y'

Looking at your error, it appears get_num_classes doesn't exist anymore. I verified this by looking that their github and docs.

It was removed after this commit.

ImportError: Cannot import name 'x'

Remove pptxbuilder.

from views.builder import builder_bp

Simple example, but the concept should be the same. Your exact code will be different of course.
Sample Image

receiving ImportError: cannot import name x from y

Your refactor.py import something from __init__.py; It makes circular import issue.


#from .__init__ import API_BASE_URL

Import error - Cannot import name x from y

Try this in scraper.py

from vendors.testing.products import TestProducts

Or

import vendors.testing.products as product 
class scraper:
def __init__(self):
self.product = product.TestProducts()

Use self.product to access any function of TestProducts inside the class scraper.

ImportError: cannot import name

The problem is that you have a circular import:
in app.py

from mod_login import mod_login

in mod_login.py

from app import app

This is not permitted in Python. See Circular import dependency in Python for more info. In short, the solution are

  • either gather everything in one big file
  • delay one of the import using local import


Related Topics



Leave a reply



Submit