0

I have the following python package created by myself:

C:.
│   .gitignore
│   MANIFEST
│   setup.py
│
├───.vscode
│   │   settings.json
│   │
│   └───.ropeproject
│           config.py
│           objectdb
│
├───calendarlib
│   │   __init__.py
│   │
│   ├───cal
│   │   │   cal.py
│   │   │   event.py
│   │   │   __init__.py
│   │   │
│   │   └───__pycache__
│   │           cal.cpython-36.pyc
│   │           calendar.cpython-36.pyc
│   │           event.cpython-36.pyc
│   │           __init__.cpython-36.pyc
│   │
│   ├───database
│   │   │   db.py
│   │   │   __init__.py
│   │   │
│   │   └───__pycache__
│   │           db.cpython-36.pyc
│   │           __init__.cpython-36.pyc
│   │
│   └───ui
│           window.py
│           __init__.py
│
├───calendarlib.egg-info
│       dependency_links.txt
│       PKG-INFO
│       SOURCES.txt
│       top_level.txt
│
└───dist
        calendarlib-0.1.tar.gz
        calendarlib-0.2.tar.gz

__init__s are empty. Now when I use this code like with creating main.py here and importing stuff, it works. But when I push it to my git repo, install it with: pip install -U git+https://github.com/frynio/calendarlib (it is present in site-packages in Python installation dir) and do something like this:

import sys
from calendarlib.ui import window

if __name__ == '__main__':
    app = window.QApplication(sys.argv)
    foo = window.CalendarWindow()
    foo.show()
    sys.exit(app.exec_())

It says:

Traceback (most recent call last):
  File "main.py", line 2, in <module>
    from calendarlib.ui import window
  File "C:\Python36\lib\site-packages\calendarlib\ui\window.py", line 4, in <module>
    from database import db
ModuleNotFoundError: No module named 'database'

The code is in here.

What can I do? Should I import it somehow different in my app, or should I change imports in calendarlib itself?

3
  • What is your setup.py? Commented May 26, 2018 at 14:16
  • It is on github: https://github.com/frynio/calendarlib Commented May 26, 2018 at 14:21
  • Well looks like the code and the error don't match calendarlib.database import db and the error says from database import db. Did you fix the issue? Commented May 26, 2018 at 14:27

1 Answer 1

1

The import should be relative to the package. from calendarlib.database import db instead of from database import db

From looking at the github repo it looks like the line is correct there... Maybe you should re-install with pip?

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.