[Tutor] ModuleNotFoundError in Terminal, PyCharm OK

trent shipley trent.shipley at gmail.com
Tue Jun 27 16:35:13 EDT 2023


PyCharm can run the code below or process the marked line, #2, in the
console, as in the snip, below, but I can't figure out how to feed the
program command line args.

import simple_hdroll_cli_parser as shdroll_cli
from app.core import core_dice_roller as core  ## problem here

parse_cli_args = shdroll_cli.SimpleHDRollCliParser()
kwargs = parse_cli_args.parse()

if kwargs.add is not None:
    transform = core.add_currying(kwargs.add)
elif kwargs.mult is not None:
    transform = core.multiply_currying(kwargs.mult)
else:
    transform = None

# Create a die
die = core.IntegerDie(transform_fn=transform,
                      sides=kwargs.sides,
                      bottom=kwargs.base)

### continues ###

No main

### END ###


A terminal on Mint Cinnamon reliably does this:

(venv) trent at trent-virtual-machine:~/pythonworkspace/hackable_dice_roller/app/cli/simple_cli$
python3 shdroll.py
Traceback (most recent call last):
  File
"/home/trent/pythonworkspace/hackable_dice_roller/app/cli/simple_cli/shdroll.py",
line 2, in <module>
    from app.core import core_dice_roller as core
ModuleNotFoundError: No module named 'app'



Google has many answers for PyCharm can't find my module, but the command
line can, but none for the other way around.


And the files:

.
├── app
│   ├── cli
│   │   ├── __init__.py
│   │   ├── __pycache__
│   │   └── simple_cli
│   │       ├── __init__.py
│   │       ├── __pycache__
│   │       ├── shdroll.py
│   │       └── simple_hdroll_cli_parser.py
│   ├── core
│   │   ├── core_dice_roller.py
│   │   ├── __init__.py
│   │   └── __pycache__
│   ├── gui
│   │   ├── __init__.py
│   │   └── simple_gui
│   │       └── __init_.py
│   ├── __init__.py
│   ├── __pycache__
│   └── tests
│       ├── cli
│       │   ├── __init__.py
│       │   └── simple_cli
│       │       └── __init__.py
│       ├── core
│       │   ├── __init__.py
│       │   ├── __pycache__
│       │   ├── test_hdr_core.py
│       │   └── test_hdr_core_visually.py
│       └── gui
│           ├── __init__.py
│           └── simple_gui
│               └── __init__.py
├── __init__.py
└── README

17 directories, 18 files


More information about the Tutor mailing list