Versions:
I have a package (mypkg) that uses django as an ORM.
I want to use this package in a client script (client / myclient / main.py).
I was able to use Django ORM directly in the client application - the problem is when I want to use it inside a package that is used by several client applications.
The package code is as follows:
# ./mypkg_wrapper/mypkg/mypkg/settings.py INSTALLED_APPS = [ 'django.contrib.contenttypes', 'myapp', ] DATABASES = { 'default': { 'ENGINE': 'django.db.backends.sqlite3', 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'), } } SECRET_KEY = '...'
I ran makemigrations, migrated to set up the database.
I ran python setup.py sdist which created mypkg_wrapper/dist/mypkg-0.0.1.tar.gz
Client Code:
# myclient/settings.py INSTALLED_APPS = [ 'django.contrib.contenttypes', 'mypkg.myapp', ] SECRET_KEY = '...'
In the venv client, I ran pip install ../mypkg_wrapper/mypkg-0.0.1.tar.gz , which seems to have successfully installed the mypkg package.
Then I tried to run python myclient/main.py , and when I tried to import mypkg.myapp, I got the following error.
ModuleNotFoundError: No module named 'mypkg'
The mypkg package is in the venv client:
$ pip list Django (2.0.3) mypkg (0.0.1) pip (9.0.1) pytz (2018.3) setuptools (28.8.0)
I saw similar questions here, but none of the answers raised this issue.
I tried / reviewed a few things:
import mypkg in main.py - same errormypkg instead of mypkg.myapp in the INSTALLED_APPS client - same error- Not sure if I need to create a database in every client? How will the database work across multiple package clients?