When i do relative import following error coming

  1. ImportError: attempted relative import with no known parent package
  2. ModuleNotFoundError: No module named ‘views’

please give me suggestion

When attempting a relative import in Python, you may encounter an error message that says “attempted relative import with no known parent package.” This error message is usually triggered when you are trying to import a module from a package using a relative import, but the package’s name is not recognized by Python as a valid package.

To fix this error, you need to make sure that the module being imported is part of a package, and that the package is on the Python path. You can do this by adding an empty init.py file to the package’s directory, and by making sure that the directory containing the package is on the Python path.

Also, you can try one or more of the following solutions:

  • Use an absolute import instead of a relative import.
  • Ensure that the package’s name is spelled correctly and that the package is located in a directory that Python can find.
  • Make sure that the package’s directory contains an init.py file, which is required for Python to recognize the directory as a package.
  • Check that you are running your Python script or program from the correct directory, which contains the package you are trying to import.
  • Consider restructuring your project to avoid using relative imports altogether.