ilmoi
ilmoi

Reputation: 2534

Python: No module named 'X'

I looked through previous answers but nothing helped. I'm running python from what seems to be the correct directory, with all the init files, and yet I'm getting the error.

Folder structure:

.
├── Pipfile
├── Pipfile.lock
├── x_logic
│   ├── __init__.py
│   ├── # logic sits here
├── dev
│   ├── __init__.py
│   └── timings
│       ├── __init__.py
│       ├── measuring_timings.py
├── ...

My command (run from the root folder, ie the one contraining Pipfile etc):

python dev/timings/measuring_timings.py

Result (measuring_timings.py is indeed importing from x_logic):

ModuleNotFoundError: No module named 'x_logic'

Same effect with and without pipenv shell.

Same effect if try to run immediately from the timings dir.

What am I missing?

Upvotes: 1

Views: 82

Answers (1)

Guillem
Guillem

Reputation: 2637

I recommend runnring the measuring_timing.py as a module, otherwise you will never be able to see the x_logic module.

$ python -m dev.timings.measuring_timings

Upvotes: 1

Related Questions