skip to Main Content

I am building a docker image. Within it I am trying to install a number of python packages within one RUN. All packages within that command are installed correctly, but PyInstaller is not for some reason, although the build logs make me think that it should have been: Successfully installed PyInstaller

The minimal Dockerfile to reproduce the issue:

FROM debian:buster

RUN apt-get update && 
    apt-get install -y 
    python3 
    python3-pip 
    unixodbc-dev 


RUN python3 -m pip install --no-cache-dir pyodbc==4.0.30 && 
    python3 -m pip install --no-cache-dir Cython==0.29.19 && 
    python3 -m pip install --no-cache-dir PyInstaller==3.5 && 
    python3 -m pip install --no-cache-dir selenium==3.141.0 && 
    python3 -m pip install --no-cache-dir bs4==0.0.1 

RUN python3 -m PyInstaller

The last run command fails with /usr/bin/python3: No module named PyInstaller, all other packages can be imported as expected.

The issue is also reproducible with this Dockerfile:

FROM debian:buster

RUN apt-get update && 
    apt-get install -y 
    python3 
    python3-pip

RUN python3 -m pip install --no-cache-dir PyInstaller==3.5 
RUN python3 -m PyInstaller 

What is the reason for this issue and what is the fix?

EDIT:

When I run the layer before the last RUN, I can see that no PyInstaller is installed, but I can run python3 -m pip install --no-cache-dir PyInstaller==3.5 and then it works without changing anything else.

2

Answers


  1. Chosen as BEST ANSWER

    Although I do not fully undestand the reason behind it, it seems like the --no-cache-dir option was causing the issue. The dockerfile below builds without an issue:

    FROM debian:buster
    
    RUN apt-get update && 
        apt-get install -y 
        python3 
        python3-pip
    
    RUN python3 -m pip install PyInstaller==3.5 
    RUN python3 -m PyInstaller --help
    

    Edit: This seems to be an issue outside of PyInstaller, but with the specific version of pip, see https://github.com/pyinstaller/pyinstaller/issues/6963 for details.


  2. I’m not familiar with PyInstaller but in their requirements page they wrote:

    If the pip setup fails to build a bootloader, or if you do not use pip
    to install, you must compile a bootloader manually. The process is
    described under Building the Bootloader.

    Have you try that in your Dockerfile?

    (And you’re totally right, it should fail… )

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