Closed enesfarukmeniz closed 6 months ago
This is a known behavior of pip. This post has many different ways to solve this problem: https://stackoverflow.com/questions/75608323/how-do-i-solve-error-externally-managed-environment-every-time-i-use-pip-3
I encountered a similar problem as reported in [GitHub Issue #2010]
#7 [ 3/10] RUN pip install openpyxl --user
#7 1.604 error: externally-managed-environment
.
.
.
------
Dockerfile:5
--------------------
3 | # Install python framework along with its dependency packages
4 | RUN apk add g++ make python3 py3-pip
5 | >>> RUN pip install openpyxl --user
6 |
7 | # Create app directory
--------------------
ERROR: failed to solve: process "/bin/sh -c pip install openpyxl --user" did not complete successfully: exit code: 1
Error: Process completed with exit code 1.
To resolve this issue, I made the following changes in the Dockerfile:
# Install python framework along with its dependency packages
RUN apk add g++ make python3 py3-pip
# Create a virtual environment and install required packages
RUN python3 -m venv ~/pyvenv --system-site-packages
RUN ~/pyvenv/bin/pip3 install openpyxl
Is it ok to close this issue then since there are ways to solve this?
For someone or me in the future, to install global cli or application you can use pipx
to install them globally, for example, it can be used to install awscli
v1 like this.
FROM node:20.12.2-alpine3.19
RUN apk update && \
apk add --no-cache --update \
python3 \
py3-pip \
pipx \
bash \
&& pipx ensurepath
ENV PATH="$PATH:/root/.local/bin"
RUN pipx install awscli
Environment
Expected Behavior
Packages should be installed without any errors
Current Behavior
Getting error while installing packages
Possible Solution
Downgrading to 18-alpine3.18
Steps to Reproduce
I use a simple Dockerfile to reproduce the error
Additional Information