0

I'm trying to develop a new Python module. This is the how my directory structure looks like:

.
├── cmd_dispatcher.py
├── commands
│   ├── __init__.py
│   └── validate.py
├── hello.py
├── README.md
├── setup.py
└── utils
    └── __init__.py

This is setup.py:

from setuptools import setup

setup(
    name='abc',
    version='1.0',
    install_requires=[
        'Click',
    ],
    entry_points='''
        [console_scripts]
        tdrivecli=cmd_dispatcher:mycli
    ''',
)

The cmd_dispatcher.py has code which does from commands.validate import validate_something

When I install this package using pip install --editable . and run $ mycli I get

  File "cmd_dispatcher.py", line 3, in <module>
    from commands.validate import validate_cst
ImportError: No module named validate

What am I missing?

Ganesh Satpute
  • 3,664
  • 6
  • 41
  • 78
  • Could try moving cmd_dispatcher.py and commands/ into src/ with an __init__.py so as to make your code a single package – Sam Redway Oct 30 '17 at 08:36

1 Answers1

0

commands is a module in Python 2.7 (https://docs.python.org/2/library/commands.html) so your package may clash with it. Make sure you don't have absolute import enabled in your cmd_dispatcher and it really can find your package.

Aleksandr Borisov
  • 2,136
  • 1
  • 13
  • 14