phkhanhtrinh23 / translation_layoutrecovery

This is a project that translates a .pdf file, preserving the original layout of that .pdf file. [UPDATED] We have achieved the Second Prize of the Cinnamon AI Bootcamp 2023.
https://youtu.be/7ua89iycdoU
48 stars 10 forks source link

Multiple errors #11

Open workphone-002 opened 6 months ago

workphone-002 commented 6 months ago

It is the first time that I use docker and honestly, I have no idea how it works, I have limited myself to following the installation instructions that you indicate but I cannot in any way get the app to work. In the installation instructions, step 3 states Important: Then, put the necessary environment files (.env) in this folder. Since I don't really know what to do in this step, I have limited myself to renaming the .env-template file to .env:

CREDENTIAL_JSON_FILE_NAME=example
STORAGE_BUCKET_NAME=example
SECRET_KEY=example

DATABASE_ENGINE=example
DATABASE_NAME=example
DATABASE_USER=example
DATABASE_PASSWORD=example
DATABASE_HOST=example
DATABASE_PORT=example

I am using a Windows 11 machine and Docker-desktop configured on wsl2

  1. The first error I got was during the process [backend 6/7] RUN pip install -r requirements.txt: 9.809 ERROR: Package 'networkx' requires a different Python: 3.8.10 not in '>=3.9' This bug was fixed by adding 'networkx==3.1' in the requirements.txt file

  2. The second error I ran into took place in [+] Running 4/3

    translation-app-frontend  | yarn run v1.22.19
    translation-app-frontend  | $ next dev
    translation-app-frontend  | /bin/sh: 1: next: not found
    translation-app-frontend  | error Command failed with exit code 127.
    translation-app-frontend  | info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
    translation-app-frontend exited with code 127

    As I said at the beginning, I have no idea about docker (or next), but by consulting some related problems I was able to solve it (or so I think) by modifying the volume configuration in the services docker-compose.yml. I'm not sure if this is correct but it apparently solved the problem:

    volumes:
      - ./Frontend:/translation-app-frontend
      - /translation-app-frontend/node_modules
  3. The third error also occurs in [+] Running 4/3:

    [+] Running 4/3
    ✔ Container translation-app-backend                                   Recreated                                     0.1s
    ! backend Published ports are discarded when using host network mode                                   0.0s
    ✔ Container translation-app-frontend                                  Recreated                                      0.1s
    ! frontend Published ports are discarded when using host network mode                                   0.0s

    I guess this is why when I access http://localhost:3000/ the page doesn't load, but although I have searched for information and it seems that using host.docker.internal instead of localhost:xxxx could be a solution as suggested in this related issue ([](https://stackoverflow.com/questions/55851632/docker-compose-network-mode -host-not-working)), I don't know where to make the modifications and therefore I haven't been able to solve it: image

  4. Finally, in addition to the previous error that I don't know how to solve, an error message always appears in [+] Running 4/3 after Successfully installed translation-app. I also don't know how to fix this error:

    translation-app-backend   | django.core.exceptions.ImproperlyConfigured: 'example' isn't an available database backend or couldn't be imported. Check the above exception. To use one of the built-in backends, use 'django.db.backends.XXX', where XXX is one of:
    translation-app-backend   |     'mysql', 'oracle', 'postgresql', 'sqlite3'
    translation-app-backend exited with code 1
dennisdebel commented 6 months ago

Hi! You are having the same issues as I do, see here. Disclamer, I have have minimal experience with all of this, especially the combination of node, django/python etc.

Error 2: This was fixed for me by manually install nvm, node, npm, yarn (globall), and in the Frontend folder install next, react, react-dom via npm and then add unmet peer dependencies in package.json (see below).

Error 3: I don't think your frontend is running since you cant visit the page... I had it running at some point but forgot how and now in more mess it seems.

Error 4: I hardcoded the credentials from .env into Backend/services/settings.py. I install and run postgres database locally (and make a database, user and password) My DATABASES section in settings.py (some parts redacted...duh). The important thing seems to be the ENGINE definition which cannot be 'postgres' it seems but is another package.

DATABASES = {
    "default": {
        "ENGINE": "django.db.backends.postgresql_psycopg2",
        "NAME": "postgres",
        "USER": "postgres",
        "PASSWORD": "redacted",
        "HOST": "localhost",
        "PORT": "5432"
    }
}

My package.json:

{
  "name": "translation-app-frontend",
  "version": "0.1.0",
  "private": true,
  "scripts": {
    "dev": "next dev",
    "build": "next build",
    "start": "next start",
    "lint": "next lint"
  },
  "dependencies": {
    "@chakra-ui/next-js": "^2.1.5",
    "@chakra-ui/react": "2.8.2",
    "@emotion/react": "^11",
    "@emotion/styled": "^11.0.0",
    "@types/node": "20.5.0",
    "@types/react": "18.2.20",
    "@types/react-dom": "18.2.7",
    "autoprefixer": "10.4.15",
    "bcrypt": "^5.1.1",
    "bcryptjs": "^2.4.3",
    "eslint": "8.47.0",
    "eslint-config-next": "13.4.13",
    "framer-motion": "4.0.0",
    "js-cookie": "^3.0.5",
    "next": "^13.5.6",
    "postcss": "8.4.27",
    "prop-types": "^15.6.0",
    "react": "^18.2.0",
    "react-dom": "^18.2.0",
    "react-dropzone": "^14.2.3",
    "react-hook-form": "^7.45.4",
    "react-infinite-scroll-component": "^6.1.0",
    "react-loading": "^2.0.3",
    "react-pdf": "^7.3.3",
    "react-toastify": "^9.1.3",
    "tailwindcss": "3.3.3",
    "typescript": "5.1.6"
  }
}