Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resolve Python Package Installation Issue Due to PEP 668 in Recent Ubuntu Versions #51

Open
hassanhah opened this issue May 14, 2024 · 1 comment

Comments

@hassanhah
Copy link

Description:
I'm encountering an error while trying to install Python packages in the system-wide Python environment on a recent version of Ubuntu. This issue seems to be related to restrictions implemented as per PEP 668, which aims to prevent conflicts between the system package manager and pip.
Steps to Reproduce:

Attempt to install a Python package using pip in the system-wide environment on a recent Ubuntu version.

sh

pip install <package-name>

Observe the error message indicating the restriction.

Expected Behavior:

Python packages should be installed successfully without conflicts.
Actual Behavior:

The installation fails with an error message due to the PEP 668 restriction.
Suggested Solution:

To resolve this issue, create a virtual environment and install the required packages within that environment. This isolates the application's dependencies from the system-wide Python environment, which is a recommended practice.
Steps to Create a Virtual Environment:

Install the virtualenv package if not already installed:

sh

sudo apt-get install python3-virtualenv

Create a new virtual environment:

sh

virtualenv myenv

Activate the virtual environment:

sh

source myenv/bin/activate

Install the required packages within the virtual environment:

sh

pip install <package-name>

References:

[PEP 668 – Marking Python base environments as “externally managed”](https://peps.python.org/pep-0668/)

Environment:

Ubuntu Version: [Specify version]
Python Version: [Specify version]
Pip Version: [Specify version]

Please look into this issue and provide guidance or a fix for the same.
external manage env

@Pavans3
Copy link

Pavans3 commented May 28, 2024

Hello everyone if You were facing this same issue just simple change Ubuntu version and your problem is resolve

FROM ubuntu:20.04

WORKDIR /app

COPY requirements.txt /app
COPY devops /app

RUN apt-get update &&
apt-get install -y python3 python3-pip &&
pip install -r requirements.txt &&
cd devops

ENTRYPOINT ["python3"]
CMD ["manage.py", "runserver", "0.0.0.0:8000"]

Screenshot (121)
Screenshot (122)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants