apt E: Unable to locate package 원인 가르기
E: Unable to locate package 는 apt update 누락, universe 꺼짐, 이름 틀림, 이 판에 없는 패키지 중 하나입니다. apt-cache policy 로 가릅니다.
E: Unable to locate package htopapt 의 패키지 목록에 그 이름이 없다는 뜻입니다. apt update 누락, 구성 요소(universe) 꺼짐, 이름 틀림, 이 판에 없는 패키지 중 하나이니 아래 순서로 지웁니다.
[1] apt update 를 먼저 돌립니다. 새로 만든 컨테이너·클라우드 이미지는 목록 폴더가 비어 있어 어떤 이름도 못 찾습니다.
# ls /var/lib/apt/lists/# apt-get install -y htopReading package lists...Building dependency tree...Reading state information...E: Unable to locate package htop목록을 받으면 같은 이름이 보입니다. Dockerfile 이라면 apt-get update && apt-get install -y … 를 한 RUN 줄에 같이 씁니다.
# apt-cache policy htop | head -3htop: Installed: (none) Candidate: 3.3.0-4build1[2] 이름을 apt-cache policy 로 확인합니다. 아무것도 안 나오면 apt 가 모르는 이름입니다. 대소문자도 구분합니다.
# apt-get install -y HtopReading package lists...Building dependency tree...Reading state information...E: Unable to locate package Htop이름이 기억나지 않으면 apt search --names-only "^neo" 처럼 이름으로만 찾습니다(--names-only 를 빼면 설명까지 뒤져 결과가 많아집니다).
[3] 명령 이름을 넣지 않았는지 봅니다. ifconfig 는 명령이고 패키지는 net-tools 입니다. 명령이나 파일 경로로 패키지를 찾을 때는 apt-file 을 씁니다(apt install apt-file && apt-file update 가 먼저).
# apt-get install -y ifconfigReading package lists...Building dependency tree...Reading state information...E: Unable to locate package ifconfig# apt-file search --regexp "bin/ifconfig$"net-tools: /sbin/ifconfigPackage python is not available, but is referred to by another package.This may mean that the package is missing, has been obsoleted, oris only available from another sourceHowever the following packages replace it: 2to3 python-is-python3 E: Package 'python' has no installation candidate[4] universe 가 켜져 있는지 봅니다. neofetch 처럼 universe 에 있는 패키지는 구성 요소를 main restricted 로 줄인 상태에서 [1]과 같은 오류가 납니다.
# grep ^Components /etc/apt/sources.list.d/ubuntu.sourcesComponents: main restrictedComponents: main restricted# apt-get install -y neofetchReading package lists...Building dependency tree...Reading state information...E: Unable to locate package neofetchUbuntu 24.04 는 저장소를 deb822 형식의 /etc/apt/sources.list.d/ubuntu.sources 에 두고, 기본으로 universe·multiverse 가 켜져 있습니다(Ubuntu Server 문서). 기본값은 Components: main universe restricted multiverse 입니다. Components: 줄 두 곳(일반·security)에 universe 를 되돌려 넣고 apt update 하면 찾습니다. Section: universe/utils 처럼 어느 구성 요소인지도 확인됩니다.
# apt-cache policy neofetch | head -6neofetch: Installed: (none) Candidate: 7.1.0-4 Version table: 7.1.0-4 500 500 http://archive.ubuntu.com/ubuntu noble/universe amd64 Packages[5] 이 판에 없는 패키지인지 봅니다. 모든 구성 요소를 켜고 apt update 까지 했는데 apt-cache policy 가 빈 줄이면 noble 저장소에 그 이름이 없는 것입니다. 시험 환경에서 fastfetch 가 그랬습니다.
# apt-cache policy fastfetch; echo "lines=$(apt-cache policy fastfetch | wc -l)"lines=0이때는 packages.ubuntu.com 에서 이름을 검색해 어느 판부터 들어 있는지 보고, 업체가 내는 공식 저장소나 .deb 를 씁니다. 업체 저장소를 붙일 때 키 경고가 나면 legacy trusted.gpg 글을 봅니다.
[6] 내려받은 .deb 파일이면 앞에 ./ 를 붙입니다. 경로 없이 파일 이름만 쓰면 apt 는 그것을 패키지 이름으로 찾습니다.
# apt-get install -y hello_*.debReading package lists...Building dependency tree...Reading state information...E: Unable to locate package hello_2.10-3build1_amd64.debE: Couldn't find any package by glob 'hello_2.10-3build1_amd64.deb'E: Couldn't find any package by regex 'hello_2.10-3build1_amd64.deb'# apt-get install -y ./hello_*.deb 2>&1 | tail -2Unpacking hello (2.10-3build1) ...Setting up hello (2.10-3build1) ...설치 중 잠금 오류가 나면 apt dpkg lock-frontend 글을, pip 로 설치하려다 막히면 pip externally-managed-environment 글을 봅니다.