I
I
Islam Ibakaev2021-01-02 23:07:19
Python
Islam Ibakaev, 2021-01-02 23:07:19

How to fix errors like "Unable to import 'django.http'"?

Raised python and django through docker to go through django tutorial. Tutorial passed, everything is fine. Only here a bunch of type "errors" (pylint swears) fell into the terminal. It looks ugly, all files are red because of underlines from pylint.
Why is pylint swearing? How to get rid of pseudo "errors"?

Dockerfile

FROM python:3.8-alpine
ENV PYTHONUNBUFFERED 1
COPY ./requirements.txt /requirements.txt
RUN pip install -r /requirements.txt

RUN mkdir /myproject
WORKDIR /myproject
COPY ./myproject /myproject

RUN adduser -D user
USER user


docker-compose.yml
version: "3"

services:
  web:
    build:
      context: .
      dockerfile: ./Dockerfile
    ports:
      - "8000:8000"
    volumes:
      - ./myproject:/myproject
    command: python manage.py runserver 0.0.0.0:8000


requirements.txt
Django>=2.2.7,<2.3.0
djangorestframework>=3.10.3,<3.11.0


example "mistakes"
61d20552440ac639571303.jpeg
variants of "errors"
61d205676b6d4697675131.jpeg

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander Karabanov, 2022-01-03
@karabanov

WORKDIR /myprojectcreates the directory itself, mkdiryou do not need to call it first.
Linter, in this situation, also needs to be run in a container.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question