0

I hate to ask a redundant question, but I am stuck and need help:

Let's say I have an example project structured like:

project/
    setup.py
    example/
        __init__.py
        prg.py
        tests/
            __init__.py
            test_foo.py

setup.py looks like:

from setuptools import setup

setup(name='example', version='0.12c',
      description='Example Description',
      author='me', author_email='me@gmail.com',
      packages=['example'])

I am trying it install it to base anaconda (windows 10, python 3.6, conda version : 4.6.3) using

python setup.py install

Everything seems fine:

Installed c:\anaconda3\lib\site-packages\example-0.12rc0-py3.6.egg
Processing dependencies for example==0.12rc0
Finished processing dependencies for example==0.12rc0

When I try and load my package in ipython:

import example

I get the following error:

In [1]: import example
---------------------------------------------------------------------------
ModuleNotFoundError                       Traceback (most recent call last)
<ipython-input-1-3ef45b82d40c> in <module>()
----> 1 import example

C:\workspace\git_clones\example\example\__init__.py in <module>()
----> 1 from prg import object1, object2

ModuleNotFoundError: No module named 'prg'

What am I not understanding?

dubbbdan
  • 2,650
  • 1
  • 25
  • 43

1 Answers1

1

Try adding a . to the import in __init__.py:

from .prg import object1, object2

See this question for a lot more information about relative imports.

Bendik
  • 1,097
  • 1
  • 8
  • 27