skip to Main Content

Trying to install a package (flake8) onto a Docker container (or maybe it’s an image). I’ve pip installed the package locally, and when I try to pip install it again, I get:

Requirement already satisfied: flake8 in c:python39libsite-packages (5.0.4)

But then when I run this code snippet:

docker-compose run --rm app sh -c "flake8"

I get the following error:

sh: flake8: not found

Using VSCode. Any ideas? Thanks

2

Answers


  1. Chosen as BEST ANSWER

    The issue was that Flake8 was only installed locally as opposed to on the Docker image (See David's comment above for more on this).

    To remedy this, the following line was added to a requirements.txt file (the numbers were for the version of the package):

    flake8>=3.9.2,<3.10
    

    And then in the Dockerfile:

    /py/bin/pip install -r /tmp/requirements.txt && 
    

  2. Use the following command to install in the docker container instead of in the base environment:

    pip install flake8
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search