No module named PyInstaller' after what appears to be a successful install

Question:

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.

Asked By: clemens

||

Answers:

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… )

Answered By: ItayB

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
Answered By: clemens
Categories: questions Tags: , , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.