Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error during installation: post-installation script fails with "externally-managed-environment" #954

Open
Chrisz7709 opened this issue Sep 1, 2024 · 13 comments

Comments

@Chrisz7709
Copy link

I'm having trouble installing Howdy (version 2.6.1). The installation fails during the post-installation script, and I get this error message:

There's a syntax warning about an invalid escape sequence, and then it says "error: externally-managed-environment." It suggests using apt install for system-wide packages or creating a virtual environment if I want to install non-Debian packages. It also mentions that I can override this with --break-system-packages, but I'm worried that could mess up my Python installation or the OS.

Steps to reproduce

I tried to install Howdy using the command sudo apt install howdy.

System Information

OS: Ubuntu  24.04.1
Howdy version: 2.6.1

Troubleshooting Steps Taken

I completely removed Howdy with sudo apt remove --purge howdy.
I ran sudo apt --fix-broken install to fix any broken packages.
I updated the package list with sudo apt update.
I made sure all required dependencies are installed, including Python and related packages.
I tried reinstalling Howdy after checking the dependencies.

Even after all this, the installation keeps failing with the same error.

Additional Notes

I really don’t want to use the --break-system-packages option because I’m worried it might cause more problems.

If anyone has run into this issue or has any suggestions on how to fix it, I’d really appreciate the help!

@jacobenosky
Copy link

I am in the exact same situation as you. Running a Dell XPS 13 2 in 1.

@ThanosSkentzos
Copy link

ThanosSkentzos commented Sep 5, 2024

I have the same issue and as I understand the situation it happens because after updating my distro my system python is now protected in a way.
Following this stack overflow post i found that i could bypass that by doing
sudo mv /usr/lib/python3.12/EXTERNALLY-MANAGED /usr/lib/python3.12/EXTERNALLY-MANAGED.old
That overcame the error about the externally managed env. However this is probably potentially dangerous because you start messing with your systems python.

However then the installation tried to upgrade my local pip env from 2.40 to 2.42 which resulted in a new error.

Using cached pip-24.2-py3-none-any.whl (1.8 MB)
Installing collected packages: pip
Attempting uninstall: pip
Found existing installation: pip 24.0
ERROR: Cannot uninstall pip 24.0, RECORD file not found. Hint: The package was installed by debian.

I tried upgrading my system pythons pip version but was not able to get it to 24.2 so the installation keeps failing


EDIT: added logs

Reading package lists... Done  
Building dependency tree... Done  
Reading state information... Done  
Suggested packages:  
  nvidia-cuda-dev  
The following NEW packages will be installed:  
  howdy  
0 upgraded, 1 newly installed, 0 to remove and 3 not upgraded.  
Need to get 0 B/38,9 kB of archives.  
After this operation, 166 kB of additional disk space will be used.  
Selecting previously unselected package howdy.  
(Reading database ... 671447 files and directories currently installed.)  
Preparing to unpack .../archives/howdy_2.6.1_all.deb ...  
Starting IR camera check...  

Trying "HD Webcam: HD Webcam"  
One of your cameras should now be on.  
Did your IR emitters turn on? [y/N]: y  

Starting certainty auto config...  


After detection, Howdy knows how certain it is that the match is correct.  
How certain Howdy needs to be before authenticating you can be customized.  

F: Fast.  
Allows more fuzzy matches, but speeds up the scanning process greatly.  

B: Balanced.  
Still relatively quick detection, but might not log you in when further away.  

S: Secure.  
The safest option, but will take much longer to authenticate you.  

You can always change this setting in the config.  
What profile would you like to use? [f/b/s]: f  

Unpacking howdy (2.6.1) ...  
Setting up howdy (2.6.1) ...  
/var/lib/dpkg/info/howdy.postinst:145: SyntaxWarning: invalid escape sequence '\w'  
  "davisking-dlib-\w+/(dlib/(http_client|java|matlab|test/)|"  


>>> Upgrading pip to the latest version  

Requirement already satisfied: pip in /usr/lib/python3/dist-packages (24.0)  
Collecting pip  
  Using cached pip-24.2-py3-none-any.whl.metadata (3.6 kB)  
Using cached pip-24.2-py3-none-any.whl (1.8 MB)  
Installing collected packages: pip  
  Attempting uninstall: pip  
    Found existing installation: pip 24.0  
ERROR: Cannot uninstall pip 24.0, RECORD file not found. Hint: The package was installed by debian.  <- HERE
Error while running last command  
dpkg: error processing package howdy (--configure):  
 installed howdy package post-installation script subprocess returned error exit status 1  
Processing triggers for man-db (2.12.0-4build2) ...  
Errors were encountered while processing:  
 howdy  
E: Sub-process /usr/bin/dpkg returned an error code (1)  

@JVT038
Copy link

JVT038 commented Sep 6, 2024

Same problem here.

Running Linux Mint with Lenovo Thinkpad L14 G5

@Onion2222
Copy link

Same problem after upgrading to Ubuntu24.04

@amirmoheb
Copy link

I have the same problem as well no matter what i do i still get cannot uinstall pip 24

@BleednIdiot
Copy link

BleednIdiot commented Sep 18, 2024

new to linux but i tried installing from source and that seems to get howdy installed but I'm running into stuff like this when I run sudo howdy add

'Traceback (most recent call last):

File "/usr/local/lib/x86_64-linux-gnu/howdy/cli.py", line 101, in
import cli.add
File "/usr/local/lib/x86_64-linux-gnu/howdy/cli/add.py", line 10, in
import numpy as np
ModuleNotFoundError: No module named 'numpy''

on Ubuntu24.04.1
in the end got it to test but it wouldn't appear in the PAM settings

@remyhuang03
Copy link

Same problem on Ubuntu24.04

@BleednIdiot
Copy link

ok found a fix basically, pip and numpy need to be updated to their latest versions for the installation to work

i believe the current versions can be found here:

/usr/lib/python3/dist-packages
so I downloaded the latest version of pip and numpy separately and used sudo nautilus to move them into the folder

now i would keep the old versions of pip and numpy and move them into a separate folder for later so you can move it back

then go ahead and install howdy

Now howdy has some issues running on version 2+ of numpy as detailed here: #928 (they may have found a solution recently)

so I would move the old install of pip back using 'sudo nautilus' and the old version of numpy as well (I ended up replacing the old pip and numpy versions so I just kept the new pip and used v 1.26 of numpy)

I think I also may have done something similar to install dlib as well
anyhow after you install you should be able to do things like 'sudo howdy test'
I ended up having some issues and needed to fix configparser as detailed in #927

@oxivanisher
Copy link

IMHO, this is a temporary workaround at best. The initial error, "error: externally-managed-environment.", tries to protect the system exactly against meddling around with the by the os installed python libraries. I think using a python virtual environment is the correct and clean solution, but I have no clue how this has to be done with a program that gets installed. Probably the venv needs to be created on a pre-inst step or so?
But with a venv, the application is completely in control of the installed libraries and is only dependent on the basic python interpreter.

@pierluigi65
Copy link

Same here with Ubuntu 24.04. Can we think to have a snap instead of a packet? Could it works?

@N0rdmann
Copy link

phew - quite a ride 🙈 How I got it to work with Mint 22 (Ubuntu 24.04 base) 😉

disabling python ext. manage lock
sudo mv /usr/lib/python3.12/EXTERNALLY-MANAGED /usr/lib/python3.12/EXTERNALLY-MANAGED.bak

installing latest >24.2 PIP manually for root
wget https://bootstrap.pypa.io/get-pip.py
sudo python3 get-pip.py

Note: be sure not to have system (apt) packages python3-numpy nor python3-pip installed before running the dpkg

installing howdy deb package ignoring it's pip requirement
sudo dpkg -i --ignore-depends=python3-pip howdy_2.6.1.deb

adding missing dlib module (should have been in install script?)
sudo pip3 install dlib

modify ConfigParser part in: howdy/pam.py
#799 (comment)

optional

disable Deprecation msg
#908

re-enabling ext. manage lock
sudo mv /usr/lib/python3.12/EXTERNALLY-MANAGED.bak /usr/lib/python3.12/EXTERNALLY-MANAGED

@yaccos
Copy link

yaccos commented Dec 17, 2024

I see that the postinstallation script in the Ubuntu PPA tries to upgrade the pip and numpy Python packages to the most recent versions which is disallowed by default on Ubuntu 24.04 (as this affects the entire system). I do not see any need for using the most recent versions, rather the opposite (see #928) appears to be true. Hence, I would think that removing the segment

log("Upgrading pip to the latest version")

# Update pip
handleStatus(sc(["pip3", "install", "--upgrade", "pip"]))


log("Upgrading numpy to the latest version")

# Update numpy
handleStatus(subprocess.call(["pip3", "install", "--upgrade", "numpy"]))

would solve the problem without causing any adverse effects. In case howdy really needs specific versions of these packages, I think a better solution would be make howdy operate its own Python virtual environment.

@rrlamichhane
Copy link

I couldn't figure out how to install howdy in debian/ubuntu without following the hacky ways that could potentially break the native Python environment and create much PITA in the future. If anyone has a way to do it without messing up the native Python environment, that would be much appreciated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests