<p>openoms suggested this <a href="https://github.com/raspiblitz/raspiblitz/blob/3c207ac909fc0654a282fe5862bfeceed47358e6/build_sdcard.sh#L380-L383" rel="nofollow noreferrer">fix</a> on Telegram to keep using pip:</p>
<blockquote>
<p>sudo rm /usr/lib/python3.*/EXTERNALLY-MANAGED</p>
</blockquote>
<p>Christian Decker added some context around Core Lightning's use of Python in its build process:</p>
<blockquote>
<p>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.</p>
<p>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 <code>--no-site-packages</code>) creates a blank page without weird combinations of system and user packages.</p>
</blockquote>

CC BY-SA 4.0
2024-02-12T17:43:06.143Z
2024-02-12T18:06:30.963Z
2024-02-12T18:06:30.963Z
Michael Folkson
<p>The reason for the issue are changes introduced recently in Python and not the policy of your VPS. There are two solutions for <a href="https://github.com/ElementsProject/lightning/pull/7103" rel="nofollow noreferrer">this</a>:</p>
<p><strong>1.</strong> Install Python dependencies with a package manager like <code>apt</code>, e.g. <code>apt install -y python3-mako python3-poetry</code>.</p>
<p><strong>2.</strong> Use <code>--break-system-packages</code> flag for pip, e.g. <code>pip install --user poetry --break-system-packages</code>.</p>
<p>The first option requires you to act as <code>root</code>, the second does not.</p>

CC BY-SA 4.0
2024-02-24T08:18:50.590Z
2024-02-24T08:59:52.430Z
2024-02-24T08:59:52.430Z
John Smith
<p>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.</p>

CC BY-SA 4.0
2024-02-13T16:19:45.127Z
2024-02-13T16:19:45.127Z
sehar talokar
<p>I tried to install Core Lightning on a Ubuntu Digital Ocean droplet using these <a href="https://github.com/ElementsProject/lightning/blob/master/doc/getting-started/getting-started/installation.md#to-build-on-ubuntu" rel="nofollow noreferrer">installation instructions</a> and it won't let me <code>pip install</code> anything giving me an error <code>externally-managed-environment</code>. Should I just use poetry instead or is there a fix?</p>

<python><core-lightning><compiling><installation>
How should I install Core Lightning if my VPS won't let me use pip install?
Michael Folkson
# How should I install Core Lightning if my VPS won't let me use pip install?

(Asked by: username_0 on 2024-02-12)

I tried to install Core Lightning on a Ubuntu Digital Ocean droplet using these [installation instructions](https://github.com/ElementsProject/lightning/blob/master/doc/getting-started/getting-started/installation.md#to-build-on-ubuntu) 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?

**Tags:** python, core-lightning, compiling, installation


---

## 3 answers

### Answer by username_0 on 2024-02-12. Score: 2 | Accepted answer

openoms suggested this [fix](https://github.com/raspiblitz/raspiblitz/blob/3c207ac909fc0654a282fe5862bfeceed47358e6/build_sdcard.sh#L380-L383) 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.


---

### Answer by username_1 on 2024-02-24. Score: 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](https://github.com/ElementsProject/lightning/pull/7103):

**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.


---

### Answer by username_2 on 2024-02-13. Score: 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.


---

