Python env error

python -m pip install --upgrade pip                                                                                                                                                                                  ✔  26s  
error: externally-managed-environment

× This environment is externally managed
╰─> To install Python packages system-wide, try 'pacman -S
    python-xyz', where xyz is the package you are trying to
    install.
    
    If you wish to install a non-Arch-packaged Python package,
    create a virtual environment using 'python -m venv path/to/venv'.
    Then use path/to/venv/bin/python and path/to/venv/bin/pip.
    
    If you wish to install a non-Arch packaged Python application,
    it may be easiest to use 'pipx install xyz', which will manage a
    virtual environment for you. Make sure you have python-pipx
    installed via pacman.

note: If you believe this is a mistake, please contact your Python installation or OS distribution provider. You can override this, at the risk of breaking your Python installation or OS, by passing --break-system-packages.
hint: See PEP 668 for the detailed specification.

Moderator edit: In the future, please use proper formatting: [HowTo] Post command output and file content as formatted text

What are you trying to do?

python -m pip install --upgrade pip
At start i tried to start Stable Diffusion but i received error and after that i tried to update pip and also receive error

I meant … what are you trying to achieve?

I want to resolve problem who bloking work of Stable Diffusion

prime-run sh webui.sh     --precision full --no-half --medvram --xformers  --autolaunch                                                               1 ✘ 

################################################################
Install script for stable-diffusion + Web UI
Tested on Debian 11 (Bullseye)
################################################################

################################################################
Running on alexbespik user
################################################################

################################################################
Repo already cloned, using it as install directory
################################################################

################################################################
Create and activate python venv
################################################################

################################################################
Launching launch.py...
################################################################
Using TCMalloc: libtcmalloc_minimal.so.4
Python 3.11.3 (main, Jun  5 2023, 09:32:32) [GCC 13.1.1 20230429]
Version: v1.5.1
Commit hash: 68f336bd994bed5442ad95bad6b6ad5564a5409a
Installing requirements
Traceback (most recent call last):
  File "/run/media/alexbespik/e8df4068-7043-49ee-928b-ecb0cf9e68fb/StableDiffusion/stable-diffusion-webui/launch.py", line 39, in <module>
    main()
  File "/run/media/alexbespik/e8df4068-7043-49ee-928b-ecb0cf9e68fb/StableDiffusion/stable-diffusion-webui/launch.py", line 30, in main
    prepare_environment()
  File "/run/media/alexbespik/e8df4068-7043-49ee-928b-ecb0cf9e68fb/StableDiffusion/stable-diffusion-webui/modules/launch_utils.py", line 358, in prepare_environment
    run_pip(f"install -r \"{requirements_file}\"", "requirements")
  File "/run/media/alexbespik/e8df4068-7043-49ee-928b-ecb0cf9e68fb/StableDiffusion/stable-diffusion-webui/modules/launch_utils.py", line 136, in run_pip
    return run(f'"{python}" -m pip {command} --prefer-binary{index_url_line}', desc=f"Installing {desc}", errdesc=f"Couldn't install {desc}", live=live)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/run/media/alexbespik/e8df4068-7043-49ee-928b-ecb0cf9e68fb/StableDiffusion/stable-diffusion-webui/modules/launch_utils.py", line 113, in run
    raise RuntimeError("\n".join(error_bits))
RuntimeError: Couldn't install requirements.
Command: "/usr/bin/python3" -m pip install -r "requirements_versions.txt" --prefer-binary
Error code: 1
stderr: error: externally-managed-environment

× This environment is externally managed
╰─> To install Python packages system-wide, try 'pacman -S
    python-xyz', where xyz is the package you are trying to
    install.
    
    If you wish to install a non-Arch-packaged Python package,
    create a virtual environment using 'python -m venv path/to/venv'.
    Then use path/to/venv/bin/python and path/to/venv/bin/pip.
    
    If you wish to install a non-Arch packaged Python application,
    it may be easiest to use 'pipx install xyz', which will manage a
    virtual environment for you. Make sure you have python-pipx
    installed via pacman.

note: If you believe this is a mistake, please contact your Python installation or OS distribution provider. You can override this, at the risk of breaking your Python installation or OS, by passing --break-system-packages.
hint: See PEP 668 for the detailed specification.
aur/stable-diffusion-intel-git r44.20230213.f90e38a-1 (+0 0.00) (Orphaned) 
    Image generator that uses stable diffusion, vino (Intel CPU) and includes "txt2img". Latest Git checkout.
aur/stable-diffusion-intel 20220908-4 (+3 0.00) (Orphaned) 
    Image generator that uses stable diffusion, vino (Intel CPU) and includes "txt2img"
aur/stable-diffusion-ui 2.5.24-1 (+7 1.45) (Out-of-date: 2023-07-30) 
    Easy Diffusion - A 1-click way to install & use Stable Diffusion on your own computer.

That being said. I do not know where from/how you installed that script you are running, or what it does, or much about anything about your system.

But reasoning seems to indicate that things are not 100% with that software for arch.

1 Like

https://github.com/AUTOMATIC1111/stable-diffusion-webui- My version of SD

i am resolved this problem
spoiler - problem was not with SD

How?

Yeah … you hadnt even got to the part where you begin installing it.
And you were using a Debian script.
(not to mention everything with pip, env, and skipping available system packages, etc)

But … do tell?

It’s not an error. The output you posted tells you what you need to know.

rm /usr/lib/python3.11/EXTERNALLY-MANAGED

The default Automatic1111 install creates and uses a venv. So I have no idea why you need to run python -m pip install --upgrade pip outside of that venv.

Anyway, you’ve now done something where you were explicitly warned that

You can override this, at the risk of breaking your Python installation or OS

so make to mention that when it does :stuck_out_tongue:

Your next topic will be “my manjaro refuses to update, throws an error abouth python”. We told ya. You now have a broken system (no wonder after using install script for another os). In the future you will have to use the pacman overwrite flag to try to update and make the system…less broken, maybe.
Also in the future: running every shell script you see on the internet with sudo is a recipe for disaster.

How can I get the /usr/lib/python3.11/EXTERNALLY-MANAGED directory back if I deleted it

(I mistook EXTERNALLY-MANAGED for a bug )
i am ran rm /usr/lib/python3.11/EXTERNALLY-MANAGED
OS Manjaro btrfs

It is just a file with the following contents

[externally-managed]
Error=To install Python packages system-wide, try 'pacman -S
 python-xyz', where xyz is the package you are trying to
 install.

 If you wish to install a non-Arch-packaged Python package,
 create a virtual environment using 'python -m venv path/to/venv'.
 Then use path/to/venv/bin/python and path/to/venv/bin/pip.

 If you wish to install a non-Arch packaged Python application,
 it may be easiest to use 'pipx install xyz', which will manage a
 virtual environment for you. Make sure you have python-pipx
 installed via pacman.

In the future, do not manually delete files from root. The system expects them to be there and sooner or later it will bite you. An consider making backups. Run Timeshift and enable automatic backups if not already enabled.

Thanks i am have timeshft but i am accidentally removed it