# Error: externally-managed-environment

**URL:** <https://discuss.python.org/t/error-externally-managed-environment/24237>\
**Category:** Python Help\
**Tags:** help\
**Created:** [February 25, 2023, 5:27pm UTC](https://discuss.python.org/t/error-externally-managed-environment/24237 "2023-02-25T17:27:28Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![0xMrR0b0t](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/0xmrr0b0t/32/11281_2.png) [@0xMrR0b0t](https://discuss.python.org/u/0xMrR0b0t)\
**Post date:** [February 25, 2023, 5:27pm UTC](https://discuss.python.org/t/error-externally-managed-environment/24237/1 "2023-02-25T17:27:28Z")

</div>

![image](https://us1.discourse-cdn.com/flex002/uploads/python1/original/2X/1/13974cd6c3a063ce4e210de5594ba248a3db9259.png)

---

<div class="post-metadata">

**Author:** ![tjreedy](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/tjreedy/32/137_2.png) [@tjreedy](https://discuss.python.org/u/tjreedy)\
**Post date:** [February 25, 2023, 9:29pm UTC](https://discuss.python.org/t/error-externally-managed-environment/24237/2 "2023-02-25T21:29:55Z")

</div>

You neglected to ask a question. You cannot use pip in the debian installed and managed python3 unless you create and use a vitual environment, using either of the two methods specified. Otherwise, use apt install.

---

<div class="post-metadata">

**Author:** ![barry-scott](https://avatars.discourse-cdn.com/v4/letter/b/e9c0ed/32.png) [@barry-scott](https://discuss.python.org/u/barry-scott)\
**Post date:** [February 26, 2023, 7:15pm UTC](https://discuss.python.org/t/error-externally-managed-environment/24237/3 "2023-02-26T19:15:23Z")

</div>

Also you cannot use `pip install --user` that I hope is a bug.

---

<div class="post-metadata">

**Author:** ![tjreedy](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/tjreedy/32/137_2.png) [@tjreedy](https://discuss.python.org/u/tjreedy)\
**Post date:** [February 26, 2023, 7:21pm UTC](https://discuss.python.org/t/error-externally-managed-environment/24237/4 "2023-02-26T19:21:08Z")

</div>

See [error: externally-managed-environment · Issue #102134 · python/cpython · GitHub](https://github.com/python/cpython/issues/102134#issuecomment-1445428402) for a much more extensive answer to the same report on a cpython issue.

---

<div class="post-metadata">

**Author:** ![barry-scott](https://avatars.discourse-cdn.com/v4/letter/b/e9c0ed/32.png) [@barry-scott](https://discuss.python.org/u/barry-scott)\
**Post date:** [February 26, 2023, 7:24pm UTC](https://discuss.python.org/t/error-externally-managed-environment/24237/5 "2023-02-26T19:24:04Z")

</div>

That is not about install --user. Its a system install.

---

<div class="post-metadata">

**Author:** ![pradyunsg](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/pradyunsg/32/206_2.png) [@pradyunsg](https://discuss.python.org/u/pradyunsg)\
**Post date:** [February 26, 2023, 7:51pm UTC](https://discuss.python.org/t/error-externally-managed-environment/24237/6 "2023-02-26T19:51:30Z")

</div>

Hmm… pip shouldn’t be printing the upgrade prompt on externally-managed environments actually.

Update: there’s now a tracking issue for this on pip.

> <https://github.com/pypa/pip/issues/11820>
>
> \### Description
> 
> It's slightly odd that pip recommends running a pip install --u…pgrade pip that cannot succeed under EXTERNALLY-MANAGED environments
> 
> \### Expected behavior
> 
> \_No response\_
> 
> \### pip version
> 
> 23.0.1
> 
> \### Python version
> 
> 3.11
> 
> \### OS
> 
> Debian
> 
> \### How to Reproduce
> 
> N/A
> 
> \### Output
> 
> \_No response\_
> 
> \### Code of Conduct
> 
> \- \[x\] I agree to follow the \[PSF Code of Conduct\](https://www.python.org/psf/conduct/).

---

<div class="post-metadata">

**Author:** ![CAM-Gerlach](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/cam-gerlach/32/3688_2.png) [@CAM-Gerlach](https://discuss.python.org/u/CAM-Gerlach)\
**Post date:** [February 27, 2023, 12:42am UTC](https://discuss.python.org/t/error-externally-managed-environment/24237/7 "2023-02-27T00:42:14Z")

</div>

No, that’s by design, because both system and user-installed packages can equally break packages in the system environment, and user-installed packages will in fact override those in the global env. See [PEP 668](https://peps.python.org/pep-0668/#motivation) for some more details.

---

<div class="post-metadata">

**Author:** ![tjreedy](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/tjreedy/32/137_2.png) [@tjreedy](https://discuss.python.org/u/tjreedy)\
**Post date:** [February 27, 2023, 2:52am UTC](https://discuss.python.org/t/error-externally-managed-environment/24237/8 "2023-02-27T02:52:09Z")

</div>

> [@barry-scott](#):
>
> That is not about install --user. Its a system install.

The error message is exactly the same, so to me, ‘same report’ is correct. The first answer to [Python3 -m pip install --user broken in debian testing](https://discuss.python.org/t/python3-m-pip-install-user-broken-in-debian-testing/24268) explains why the same message is appropriate to both command variations.

---

<div class="post-metadata">

**Author:** ![CAM-Gerlach](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/cam-gerlach/32/3688_2.png) [@CAM-Gerlach](https://discuss.python.org/u/CAM-Gerlach)\
**Post date:** [March 1, 2023, 2:58am UTC](https://discuss.python.org/t/error-externally-managed-environment/24237/10 "2023-03-01T02:58:17Z")

</div>

While we appreciate you’re trying to help, the very first reply (and the error message itself) already explained the problem, and a fully complete answer was [already linked above](https://discuss.python.org/t/error-externally-managed-environment/24237/4).

Particularly with that in mind, I would ask that you please avoid spreading potentially dangerous advice that users are likely to copy and paste without fully understanding the consequences, at least without first presenting other better ways of solving this problem, explaining _exactly_ what that flag does, and providing a clear disclaimer that they should not try it unless they know _exactly_ what they are doing, are prepared to break things and none of the other options will work for their particular use case. Thanks.

---

<div class="post-metadata">

**Author:** ![barry-scott](https://avatars.discourse-cdn.com/v4/letter/b/e9c0ed/32.png) [@barry-scott](https://discuss.python.org/u/barry-scott)\
**Post date:** [March 2, 2023, 2:37pm UTC](https://discuss.python.org/t/error-externally-managed-environment/24237/11 "2023-03-02T14:37:05Z")

</div>

I was also was surprised and confused by the pip message.

The point I had not picked up on is that it seems apart from Fedora using -s no one else is.  
I’m a Fedora used mostly and knew that pip install --user on Fedora is safe to use.

That message did not make sense too me as I did not think I was doing what it told me was happening. e.g. I was not installing into the system as far as my understanding was.

---

<div class="post-metadata">

**Author:** ![CAM-Gerlach](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/cam-gerlach/32/3688_2.png) [@CAM-Gerlach](https://discuss.python.org/u/CAM-Gerlach)\
**Post date:** [March 3, 2023, 8:05am UTC](https://discuss.python.org/t/error-externally-managed-environment/24237/12 "2023-03-03T08:05:46Z")

</div>

The message is set by the distro in the `EXTERNALLY-MANGED` file, not by `pip` (unless the distro has not set one as it should, in which case the installer displays a fallback default message—but as this one references a specific distro, presumably that’s not what happened). Therefore, you should presumably bring that up with your distro. It does appear that essentially the example message [from the PEP](https://peps.python.org/pep-0668/#specification) is being used, so perhaps the distro neglected to properly customize it?

---

<div class="post-metadata">

**Author:** ![CAM-Gerlach](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/cam-gerlach/32/3688_2.png) [@CAM-Gerlach](https://discuss.python.org/u/CAM-Gerlach)\
**Post date:** [March 16, 2023, 11:26am UTC](https://discuss.python.org/t/error-externally-managed-environment/24237/14 "2023-03-16T11:26:26Z")

</div>

Hi @vishalpa8 and welcome to the Python Discourse! While we appreciate you’re trying to help, as I mentioned to another user a few comments up, the very first reply (and the error message itself) already explained the problem, and a fully complete answer was [already linked above](https://discuss.python.org/t/error-externally-managed-environment/24237/4).

Particularly with that in mind, I would ask that you please avoid spreading potentially dangerous advice that users are likely to copy and paste without fully understanding the consequences, at least without first presenting other better ways of solving this problem, explaining _exactly_ what that flag does, and providing a clear disclaimer that they should not try it unless they know _exactly_ what they are doing, are prepared to break things and none of the other options will work for their particular use case. Thanks.

As such I’ve unfortunately had to go ahead and hide your post, to avoid other users seeing it, copy-pasting and breaking their operating system. Sorry about that!

---

<div class="post-metadata">

**Author:** ![CAM-Gerlach](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/cam-gerlach/32/3688_2.png) [@CAM-Gerlach](https://discuss.python.org/u/CAM-Gerlach)\
**Post date:** [March 25, 2023, 1:10pm UTC](https://discuss.python.org/t/error-externally-managed-environment/24237/15 "2023-03-25T13:10:44Z")

</div>

Just to ensure anyone reading the thread doesn’t miss it, as others have noted above, see [this GitHub post](https://github.com/python/cpython/issues/102134#issuecomment-1445428402) for a full explanation of why you’re seeing this message and what you should do about it. Thanks!
