Workaround externally managed environment issue in Python 3.11#150
Closed
gene1wood wants to merge 3 commits intosystemd:mainfrom
Closed
Workaround externally managed environment issue in Python 3.11#150gene1wood wants to merge 3 commits intosystemd:mainfrom
gene1wood wants to merge 3 commits intosystemd:mainfrom
Conversation
Around the beginning of 2025, the `ubuntu-latest` runner image
which [this project uses][1], [was changed from Ubuntu 22.04 to 24.04][2].
As a result, the python version which is used by this repo's GitHub actions
changed from [3.10.12][3] to [3.12.3][4].
With this change to Python 3.12, [PEP 668][5] was introduced. This new Python
behavior is causing errors in the CI and `pip` is exiting non-zero
```
error: externally-managed-environment
× This environment is externally managed
╰─> To install Python packages system-wide, try apt install
python3-xyz, where xyz is the package you are trying to
install.
If you wish to install a non-Debian-packaged Python package,
create a virtual environment using python3 -m venv path/to/venv.
Then use path/to/venv/bin/python and path/to/venv/bin/pip. Make
sure you have python3-full installed.
If you wish to install a non-Debian packaged Python application,
it may be easiest to use pipx install xyz, which will manage a
virtual environment for you. Make sure you have pipx installed.
See /usr/share/doc/python3.13/README.venv for more information.
```
This adds a `--break-system-packages` argument to the `pip install` so that
it can continue to install packages without an error.
A possible future improvement would be to do these installations in a virtual
environment.
[1]: https://github.com/systemd/python-systemd/blob/903142423452c4dd18110b7f8a953dabb2031e49/.github/workflows/install.yml#L17
[2]: actions/runner-images#10636
[3]: https://github.com/actions/runner-images/blob/main/images/ubuntu/Ubuntu2204-Readme.md#installed-software
[4]: https://github.com/actions/runner-images/blob/main/images/ubuntu/Ubuntu2404-Readme.md#language-and-runtime
[5]: https://peps.python.org/pep-0668/
Author
|
It looks like the CI is a bit out of date. I'll close this PR and come up with another one that fixes all of the CI issues. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Around the beginning of 2025, the
ubuntu-latestrunner image which this project uses, was changed from Ubuntu 22.04 to 24.04.As a result, the python version which is used by this repo's GitHub actions changed from 3.10.12 to 3.12.3.
With this change to Python 3.12, PEP 668 was introduced. This new Python behavior is causing errors in the CI and
pipis exiting non-zeroThis adds a
--break-system-packagesargument to thepip installso that it can continue to install packages without an error.A possible future improvement would be to do these installations in a virtual environment.