0

I have replicated the scenario in this exact question:

Python error - ImportError: attempted relative import with no known parent package

However, the answer for me does not work. I'm running python3 (3.7.9) in VSCode with the following file structure:

project/
├─ utils/
│  ├─ module.py
├─ server/
│  ├─ main.py

When in the directory all_projects/project/server/:

Running python3 main.py I get ImportError: attempted relative import with no known parent package

Running python3 -m main: ImportError: attempted relative import with no known parent package

-

When in the directory all_projects/project/:

Running python3 -m server.main: ValueError: attempted relative import beyond top-level package

-

ONLY when in the directory all_projects/:

Running python3 -m project.server.main: works as expected.

What the hell is going on here? Why does python3 -m server.main not work in the project directory?

CaitlynCodr
  • 238
  • 1
  • 15

1 Answers1

0

it could be anything ! including permissions! but you should use virtualenv

javadfarah
  • 46
  • 5