2

I tried to install Core Lightning on a Ubuntu Digital Ocean droplet using these installation instructions and it won't let me pip install anything giving me an error externally-managed-environment. Should I just use poetry instead or is there a fix?

3 Answers 3

2

openoms suggested this fix on Telegram to keep using pip:

sudo rm /usr/lib/python3.*/EXTERNALLY-MANAGED

Christian Decker added some context around Core Lightning's use of Python in its build process:

Python is not a runtime dependency, which is why it is not being listed as a direct dependency, but we use it for a variety of build steps. The error you received is because the pip environment is owned by root since you installed it via the package manager. If you want to install the build dependencies we strongly suggest using a virtualenv. Steps on how to set that up depend on the OS, and your Python setup, hence why it is left undocumented (it's not CLN specific, and any documentation on how to create virtualenvs would bitrot, and we can't be authoritative anyway, since it is an external project). We just need to find a good point to cut off the long tail, and for venv that was the place that felt right.

Python dependency management grew quite organically, which explains the mess of different ideas and models being mixed. Usually you have the system environment, which you can extend through a user environment that gets overlaid. This does not work however if a user package clashes with a system package. We seem to rely on rather recent package versions, that may clash, causing this error. A virtualenv (initialized with --no-site-packages) creates a blank page without weird combinations of system and user packages.

1

Check environment variables: Some Docker containers or cloud environments might restrict pip commands. Ensure variables like PIP_NO_INDEX or PIP_DISABLE_PYPI are not set to restrict package installations. Check user permissions: You may need root or sudo privileges to use pip install. Try using sudo pip install if appropriate. Isolate the issue: Create a new virtual environment and try installing Core Lightning there. This helps identify if the issue is specific to your current environment. Consider alternative package managers: If pip continues to cause issues, try installing dependencies using apt or other package managers compatible with your Ubuntu version.

1

The reason for the issue are changes introduced recently in Python and not the policy of your VPS. There are two solutions for this:

1. Install Python dependencies with a package manager like apt, e.g. apt install -y python3-mako python3-poetry.

2. Use --break-system-packages flag for pip, e.g. pip install --user poetry --break-system-packages.

The first option requires you to act as root, the second does not.

Not the answer you're looking for? Browse other questions tagged or ask your own question.