I have a python package I published on PyPI, my file structure is this:
- setup.py
- example.py
- ...
- igloo
- __init__.py
- ...
- models
- __init__.py
- user.py
- ...
inside the file igloo/__init__.py
I have this import statement
from igloo.models.user import User
When I import the package igloo from the example.py
file (the import resolves to the folder igloo) everything works as expected, but when I install the package from pip and import it I get the error ModuleNotFoundError: No module named 'igloo.models'
on the import line from the file igloo/__init__.py
. In both cases I import the package like this:
from igloo import Client
The setup.py
file is like this
from distutils.core import setup
setup(
name='igloo-python', # How you named your package folder (MyLib)
packages=['igloo'], # Chose the same as "name"
version='0.9.3',
license='MIT',
description='Python client for igloo',
author='Igloo Team',
author_email='hello@igloo.ooo',
url='https://github.com/IglooCloud/igloo_python',
download_url='https://github.com/IglooCloud/igloo_python/archive/v_09.tar.gz',
keywords=['iot', 'igloo'],
install_requires=[
'requests', 'asyncio', 'pathlib', 'websockets', 'aiodataloader'
],
classifiers=[
'Development Status :: 5 - Production/Stable',
'Intended Audience :: Developers',
'Topic :: Software Development ',
'License :: OSI Approved :: MIT License ',
'Programming Language :: Python :: 3',
],
)
I also tried replacing the import in igloo/__init__.py
with
from .models.user import User
the same error pops up also in this case.