Rename cts_sap_polaris.py to something else.

This name conflicts with the package name (which has the same name).

(credit goes to @jedwards on his comment)

Answer from jersey bean on Stack Overflow
๐ŸŒ
Reddit
reddit.com โ€บ r/learnpython โ€บ import error: 'x' is not a package
r/learnpython on Reddit: Import error: 'x' is not a package
April 18, 2020 -

I'm working on a program that lets the user do mad libs, and I'm importing the prompts from a file in a subdirectory (prompts being "enter a noun", for example). The file tree looks something like this:

    Mad Libs
        |
       libs
        /\
    lib 1 lib2
    /\
prompts.py text.txt

if I import from a test file in the "Mad Libs" directory, it imports just fine. But if I import from the main program, I get this error:

ModuleNotFoundError: No module named 'libs.lib 1.prompts.py'; 'libs.lib 1.prompts' is not a package

I'm using the importlib module for imports, since they're based on user-entered strings.

Any ideas what's going on here?

๐ŸŒ
freeCodeCamp
freecodecamp.org โ€บ news โ€บ module-not-found-error-in-python-solved
ModuleNotFoundError: no module named Python Error [Fixed]
September 12, 2022 - In Python, you can import modules from other files using absolute or relative paths. For this example, I'll focus on absolute paths. When you try to access a module from the wrong path, you will also get the module not found here. Here's an example: Let's say you have a project folder called test. In it, you have two folders demoA and demoB. demoA has an __init__.py file (to show it's a Python package...
๐ŸŒ
pythontutorials
pythontutorials.net โ€บ blog โ€บ importerror-with-error-is-not-a-package
How to Fix ImportError: 'is not a package' in Python 3 โ€“ Troubleshooting Project Structure Issues
Relative imports (e.g., from . import module) only work in modules that are part of a package. If you run a script directly (e.g., python script.py), it becomes the __main__ module and is not considered part of a package.
๐ŸŒ
Reddit
reddit.com โ€บ r/vscode โ€บ i have a problem with importing packages in python
r/vscode on Reddit: i have a problem with importing packages in python
August 3, 2023 -

In my python script I wrote:

import package.module
package.module.b()

for some reason it cant find the package and also calls it a module in the error

ModuleNotFoundError: No module named 'package'

i checked the spelling and the names of the module and the package

if you explain this it would me a lot thanks!

๐ŸŒ
Curiousefficiency
python-notes.curiousefficiency.org โ€บ en โ€บ latest โ€บ python_concepts โ€บ import_traps.html
Traps for the Unwary in Pythonโ€™s Import System - Alyssa Coghlan's Python Notes
This has changed in Python 3.3: now any directory on sys.path with a name that matches the package name being looked for will be recognised as contributing modules and subpackages to that package. ... With that layout and the current working directory being project, Python 2.7 gives the following behaviour: $ python2 -c "import example.foo" Traceback (most recent call last): File "<string>", line 1, in <module> ImportError: No module named example.foo
๐ŸŒ
Python documentation
docs.python.org โ€บ 3 โ€บ reference โ€บ import.html
5. The import system โ€” Python 3.15.1 documentation
Portions may also be found in zip files, on the network, or anywhere else that Python searches during import. Namespace packages may or may not correspond directly to objects on the file system; they may be virtual modules that have no concrete representation.
๐ŸŒ
Towards Data Science
towardsdatascience.com โ€บ home โ€บ programming โ€บ how to fix modulenotfounderror and importerror
How to Fix ModuleNotFoundError and ImportError | Towards Data Science
September 13, 2020 - Now if the module's name was not found either in sys.modules nor in standard library, Python will finally attempt to resolve it under sys.path. And this is the point where things can certainly go wrong. I believe most Python programmes are quite familiar with ModuleNotFoundError ... In absolute imports, we specify the explicit path starting from the project's root directory.
Find elsewhere
Top answer
1 of 3
100

The issue was in the naming of my file.

I hastily named my file emailage.py and then tried to import from emailage.client.

I'm assuming that Python looked in my current directory and matched the names of the file I was working on before checking the installed third party libraries.

After renaming my file everything seems ok.

For others who run into similar problems -- beware of conflicting naming. Sometimes the simplest things trip you up the longest.

2 of 3
44

I ran into something similar and the answer from OP about namespace collision is what finally clued me in.

I was using the same name for both a sub-package (directory) and a module (file) within it.

For example I had this:

/opt/mylib/myapi
/opt/mylib/myapi/__init__.py
/opt/mylib/myapi/myapi_creds.py        # gitignored file for user/pass
/opt/mylib/myapi/myapi.py              # base module, load creds and connect
/opt/mylib/myapi/myapi_dostuff.py      # call myapi.py and do work

The script 'myapi.py' imports credentials from myapi_creds.py via this statement:

from myapi.myapi_creds import my_user, my_pass

Testing the module 'myapi.py' resulted in this error:

$ ./myapi.py
Traceback (most recent call last):
  File "./myapi.py", line 12, in <module>
    from myapi.myapi_creds import my_user, my_pass
  File "/opt/mylib/myapi/myapi.py", line 12, in <module>
    from myapi.myapi_creds import my_user, my_pass
ModuleNotFoundError: No module named 'myapi.myapi_creds'; 'myapi' is not a package

The solution was to rename myapi.py to myapi_base.py so it's name does not collide with the sub-package name.

๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ python โ€บ how-to-fix-importerror-attempted-relative-import-with-no-known-parent-package
How to Fix: ImportError: attempted relative import with no known parent package - GeeksforGeeks
July 23, 2025 - Below are the solution for ImportError: Attempted Relative Import With No Known Parent Package in Python: ... To fix the error, remove relative imports when running the script directly, or execute the script using the -m flag.
๐ŸŒ
GitHub
github.com โ€บ python โ€บ importlib_resources โ€บ issues โ€บ 60
Using __name__ on a non-package module results in "not a package" error ยท Issue #60 ยท python/importlib_resources
October 21, 2020 - In other words, importlib_resources seems to be more stringent about the input, requiring the parameter to be a package and not simply a module.
Author: python
๐ŸŒ
Reddit
reddit.com โ€บ r/learnpython โ€บ unable to import recently downloaded packages, receiving module not found error
r/learnpython on Reddit: Unable to import recently downloaded packages, receiving module not found error
April 25, 2023 -

Several of the last modules or packages have failed to be found by the python ide. I successfully installed each package via pip and am sure they are all up to date, including pip3, the python3 version, IDLE, the modules themselves, everything. updated all the packages together in pip list as well. IDE successfully imports some modules but not others.

Recently installed packages that do not work include:
selenium, scikit-learn, retrying, seaborn, matplotlib.
Recent packages that do work include:
tensorflow, numpy etc (although some required some additional troubleshooting, they were ultimately successfully installed in the right paths)

the sys.path is correct, the packages are all going to the same path/directories as all my other modules/packages which work fine, and python is successfully from these directories. In the few instances where an additional path was required I added that and the package installed fine, but this wasn't the problem in the rest of the installed packages. Ive gone through every troubleshooting tip imaginable such as uninstalling, reinstalling, checking dependencies, root privilege, update, restarting the ide, clearing caches, anything!

example errors

% pip install selenium
...
...
Successfully installed selenium-4.9.0

import selenium
Traceback (most recent call last):
  File "<pyshell#40>", line 1, in <module>
    import selenium
ModuleNotFoundError: No module named 'selenium'

Traceback (most recent call last):
  File "/Users/user/Pyprojects/test.py", line 6, in <module>
    from retrying import retry
ModuleNotFoundError: No module named 'retrying'

why does this work for some but not others? whats the difference between one or the other, theyre all packages? some files seem to try to install into different directories but i added them all to the system path

please let me know if theres any other information you need to help diagnose the problem, or don't hesitate to mention any issues or fixes you encountered that might be similar

๐ŸŒ
Stack Overflow
stackoverflow.com โ€บ questions โ€บ 53646480 โ€บ python-package-cannot-be-imported
Python package cannot be imported - Stack Overflow
_my_module() should only be referenced from within the package holding it ยท That being said, this convention is meant to be a hint to other developers, not a strict prohibition. Perhaps the first step you can take to solve the import issue is to rename _util.py to util.py and proceed from there.
๐ŸŒ
Note.nkmk.me
note.nkmk.me โ€บ home โ€บ python
How to Import Modules, Packages, Functions in Python | note.nkmk.me
May 12, 2023 - Check and add the module search ... cases, use from to import a function or a class. This error indicates that the imported module does not have the specified attribute....
๐ŸŒ
Career Karma
careerkarma.com โ€บ blog โ€บ python โ€บ python modulenotfounderror solution
Python ModuleNotFoundError Solution | Career Karma
December 1, 2023 - You cannot install modules for Python 3 using pip and modules for Python 2 using pip3. If you do, the Python interpreter may not recognize that you have installed a module. ... Our code works! There are two types of imports in Python: absolute and relative. Absolute imports are where you import something on sys.path, like a built-in package.
๐ŸŒ
Quentin Fortier
fortierq.github.io โ€บ python-import
How to import local modules with Python - Quentin Fortier
May 9, 2021 - ~/Documents/code/project$ python3 src/a/b.py Traceback (most recent call last): File "src/a/b.py", line 4, in <module> from ..c import d ImportError: attempted relative import with no known parent package ยท This is not working! Indeed, relative imports rely on the __name__ or __package__ variable (which is __main__ and None for a script, respectively).
๐ŸŒ
Reddit
reddit.com โ€บ r/learnpython โ€บ importerror: attempted relative import with no known parent package
r/learnpython on Reddit: ImportError: attempted relative import with no known parent package
July 9, 2022 -

Hi all!

Say I have this folderstructure:

package
โ”œโ”€โ”€ __init__.py
โ”œโ”€โ”€ module.py
โ””โ”€โ”€ subpackage
    โ”œโ”€โ”€ bar.py
    โ”œโ”€โ”€ __init__.py
    โ””โ”€โ”€ subsubpackage
        โ”œโ”€โ”€ __init__.py
        โ””โ”€โ”€ foo.py

And I would like to import a function called 'func' from 'bar.py' into 'foo.py. How would I do this?

I tried literally every combination possible...like:

from .bar import func

from subpackage.bar import func

from ..bar import func

from . import bar.func

Problem is....nothing works, as I always get this error:

ImportError: attempted relative import with no known parent package

When I read on stackoverflow, I read a lot of different answers, most of them involving manipulating sys.path and quite complex.

I dont really understand why such a simple thing would be so complicated...what am I missing here?

๐ŸŒ
OneUptime
oneuptime.com โ€บ home โ€บ blog โ€บ how to fix 'importerror: no module named' in python
How to Fix 'ImportError: No module named' in Python
January 26, 2026 - When Python encounters an import ... ModuleNotFoundError: No module named 'requests' The most common cause is simply that the package is not installed....
๐ŸŒ
Dzyoba
alex.dzyoba.com โ€บ blog โ€บ python-import
Hitchhiker's guide to the Python imports | There is no magic here
January 13, 2018 - Any directory with __init__.py by convention is a Python package. Besides making a package __init__.py conveys one more purpose โ€“ package initialization. Thatโ€™s why itโ€™s called init after all! Initialization is triggered on the package import, in other words importing a package invokes __init__.py