Raj Oberoi
Raj Oberoi

Reputation: 774

setup.py in python showing 'ModuleNotFoundError: No module named' altough it exists and is there

I have a small app in the structure folder 'base' and the child folder as base>start. To package it I have a setup.py in folder base. The code of which is

setup(name='bashed',
      version='0.1.0',
      packages=find_packages(),
      #packages=[start],
      entry_points={
          'console_scripts': [
              'bashed = start.__main__:main'
          ]
      },
      )

In the child folder, 'start', I have a file called __main__.py with a 'main' method.

When I run the command

python setup.py install

followed by

bashed

I get the error ModuleNotFoundError: No module named 'start'

However when I run the command

python setup.py develop

followed by

bashed

The function 'main' in 'start.__main__.py' is executed.

I have tried using
packages=find_packages() as well as packages=[start] in the setup.py but did not work

The content of setup.py includes

setup(name='bashed',
      version='0.1.0',
      packages=find_packages(),
      #packages=[start],
      entry_points={
          'console_scripts': [
              'bashed = start.__main__:main'
          ]
      },
      )

The content of start.main.py is below

def main():
    print("This is the main routine.")

if __name__ == "__main__":
    main()

Upvotes: 1

Views: 2507

Answers (1)

sinoroc
sinoroc

Reputation: 22295

Either use packages=['start'] (note the single quotes) or if you use packages=find_packages() make sure you have a start/__init__.py file.

Upvotes: 2

Related Questions