Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Appendix DjangoProject - ModuleNotFoundError: No module named 'alloc' #38

Open
dmgolembiowski opened this issue Aug 13, 2021 · 1 comment

Comments

@dmgolembiowski
Copy link

dmgolembiowski commented Aug 13, 2021

Description

make all fails during pytest step.

Demonstration

$ git checkout appendix_django
$ make all
docker-compose down --remove-orphans
Removing cosmic-python_postgres_1 ... done
Removing network cosmic-python_default
docker-compose build
postgres uses an image, skipping
WARNING: Native build is an experimental feature and could change at any time
Building app
[+] Building 0.5s (13/13) FINISHED                                                                                                                                                                                
 => [internal] load build definition from Dockerfile                                                                                                                                                         0.0s
 => => transferring dockerfile: 38B                                                                                                                                                                          0.0s
 => [internal] load .dockerignore                                                                                                                                                                            0.1s 
 => => transferring context: 2B                                                                                                                                                                              0.0s 
 => [internal] load metadata for docker.io/library/python:3.9-slim-buster                                                                                                                                    0.3s 
 => [internal] load build context                                                                                                                                                                            0.0s
 => => transferring context: 2.18kB                                                                                                                                                                          0.0s 
 => [1/8] FROM docker.io/library/python:3.9-slim-buster@sha256:182f0eff727af9fccf88294dbfffb23ad408369c412e1267ddd5aa63ef8b5bf8                                                                              0.0s 
 => CACHED [2/8] COPY requirements.txt /tmp/                                                                                                                                                                 0.0s 
 => CACHED [3/8] RUN pip install -r /tmp/requirements.txt                                                                                                                                                    0.0s 
 => CACHED [4/8] RUN mkdir -p /src                                                                                                                                                                           0.0s 
 => CACHED [5/8] COPY src/ /src/                                                                                                                                                                             0.0s 
 => CACHED [6/8] RUN pip install -e /src                                                                                                                                                                     0.0s 
 => CACHED [7/8] COPY tests/ /tests/                                                                                                                                                                         0.0s 
 => CACHED [8/8] WORKDIR /src                                                                                                                                                                                0.0s 
 => exporting to image                                                                                                                                                                                       0.1s 
 => => exporting layers                                                                                                                                                                                      0.0s
 => => writing image sha256:9566a0aa0ba5691e04eaa23ea011c4047413369f81d62e4eca26c9f7528927be                                                                                                                 0.0s 
 => => naming to docker.io/library/cosmic-python_app                                                                                                                                                         0.0s
Successfully built 9566a0aa0ba5691e04eaa23ea011c4047413369f81d62e4eca26c9f7528927be
docker-compose up -d app
WARNING: Native build is an experimental feature and could change at any time
Creating network "cosmic-python_default" with the default driver
Creating cosmic-python_postgres_1 ... done
Creating cosmic-python_app_1      ... done
docker-compose run --rm --no-deps --entrypoint=pytest app /tests/unit /tests/integration /tests/e2e
WARNING: Native build is an experimental feature and could change at any time
Creating cosmic-python_app_run ... done
Traceback (most recent call last):
  File "/usr/local/lib/python3.9/site-packages/django/apps/config.py", line 244, in create
    app_module = import_module(app_name)
  File "/usr/local/lib/python3.9/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
  File "<frozen importlib._bootstrap>", line 984, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'alloc'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/bin/pytest", line 8, in <module>
    sys.exit(console_main())
  (... snip ...)
@dmgolembiowski
Copy link
Author

I'm opening a PR with the fix.

1Mark pushed a commit to 1Mark/code that referenced this issue Jul 6, 2022
django app fails to boot for two reasons

Issue 1:
-------
ModuleNotFoundError: No module named 'alloc'
Fix:
app name needs to be the path
https://stackoverflow.com/a/67057826/5506988

Same as issue cosmicpython#38 but issue 2 started when trying to fix
issue cosmicpython#38

Issue 2:
-------
psycopg2.errors.UndefinedColumn: column c.relispartition does not exist
django version is not fixed and in django 4 something broke
https://stackoverflow.com/questions/69477858/django-error-column-does-not-exist-but-i-have-no-control-over-that-table#comment122830337_69477858

Fix:
Hardcode django version in requirements.txt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant