title: Unable to load submodules of a Python package: ModuleNotFoundError: No module named
body: <p>I am new to Python. This looks like a very simple problem but I am unable to solve it after trying my best.</p>
  <p>I am trying to publish a python package that I developed to an artifact store. However, when I download the package on a target machine, it runs into the error about inner modules not found. The packaging and installation both look good. The output messages show that it does include the submodules.</p>
  <p>I have a directory structure as per below.</p>
  <pre><code>samplepackage/
          hello.py
          __init__.py
          dir1/
              __init__.py
             dir1pkg.py
  </code></pre>
  <p>Below are the contents of the files. The init files are empty.</p>
  <h3>hello.py</h3>
  <pre><code>import sys
  from dir1.dir1pkg import dir1pkg
  
  def main ():
      dirpkg = dir1pkg('This is msg')
      dirpkg.printmsg()
  
  if __name__ == &quot;__main__&quot;:
      main()
  </code></pre>
  <h3>dir1pkg.py</h3>
  <pre><code>class dir1pkg:
      def __init__(self,msg):
          self.msg = msg
          
      def printmsg(self):
          print(self.msg)
  </code></pre>
  <h3>setup.py</h3>
  <pre><code>import setuptools
  from setuptools import setup, find_packages, find_namespace_packages
  
  setup(
      name=&quot;samplepackage&quot;, 
      version=&quot;0.0.3&quot;,
      author=&quot;myname&quot;,
      author_email=&quot;myemail@email.com&quot;,
      description=&quot;This is a sample package&quot;,
      long_description=&quot;This is long description&quot;,
      long_description_content_type=&quot;text/markdown&quot;,
      packages=setuptools.find_packages(),
      include_package_data=True,
      classifiers=[
          &quot;Programming Language :: Python :: 3&quot;,
          &quot;License :: OSI Approved :: MIT License&quot;,
          &quot;Operating System :: OS Independent&quot;,
      ],
      entry_points={
          &quot;console_scripts&quot;:[
              &quot;samplepackage=samplepackage.hello:main&quot;
          ]
      }
      ,python_requires='&gt;=3.7'
  )
  
  </code></pre>
  <p>Below is how I am packaging and publishing to artifacts repo.</p>
  <pre><code>python setup.py sdist bdist_wheel
  twine upload --config-file &quot;.pypirc&quot; -r &lt;artifact_feed&gt; dist/*
  </code></pre>
  <p>Below is how I am installing on the target.</p>
  <pre><code>python -m pip install --upgrade samplepackage
  python -m SamplePackage.hello.py
  </code></pre>
  <p>This gives me the error below</p>
  <pre>
  C:\Users\manan\Desktop>python -m samplepackage.hello.py
  Traceback (most recent call last):
    File "C:\Users\manan\AppData\Local\Programs\Python\Python38\lib\runpy.py", line 185, in _run_module_as_main
      mod_name, mod_spec, code = _get_module_details(mod_name, _Error)
    File "C:\Users\manan\AppData\Local\Programs\Python\Python38\lib\runpy.py", line 111, in _get_module_details
      __import__(pkg_name)
    File "C:\Users\manan\AppData\Local\Programs\Python\Python38\lib\site-packages\samplepackage\hello.py", line 2, in 
      from dir1.dir1pkg import dir1pkg
  ModuleNotFoundError: No module named 'dir1'
  </pre>
  <p>However, this runs just fine from where I am developing the package. I can execute below and it is able to find the inner module without any issues.</p>
  <pre>
  C:\Users\mdmehta\Desktop\PythonPackage\samplepackage>python hello.py
  This is msg
  </pre>
  <p>I have tried doing a lot of twicks around setup.py but none of them work. Even the output of the installed package looks good. I do see dir1 being included as a package.</p>
  <pre>
  >>> help('samplepackage')
  Help on package samplepackage:
  
  NAME
      samplepackage
  
  PACKAGE CONTENTS
      dir1 (package)
      hello
  
  FILE
      c:\users\mdmehta\appdata\local\programs\python\python38\lib\site-packages\samplepackage\__init__.py
  </pre>