Search code examples
pythonimportmoduleimporterrortraceback

I'm getting Import Error: No Module Named ecommerce.shipping in Python


I'm trying to import the "shipping" module in "try.py" but I'm getting this error.

  Traceback (most recent call last):
  File "try.py", line 1, in <module>
    from ecommerce.shipping import calc_shipping
ImportError: No module named ecommerce.shipping

What do you think is the problem? here is the image of my project structure [1]: https://i.sstatic.net/F8L31.png


Solution

  • If it's inside the same directory as the script you can import it directly like this:

    from shipping import calc_shipping