내가 할 때
which pip3
나는 얻다
/usr/local/bin/pip3
그러나 실행하려고하면 pip3
다음과 같은 오류가 발생합니다.
bash: /usr/bin/pip3: No such file or directory
최근에 해당 파일을 삭제했기 때문입니다. 이제 which
또 다른 버전으로 명령 점을 pip3
그에 위치하고 /usr/local/bin
있지만, 쉘은 여전히 잘못된 경로를 기억합니다. 그 길을 잊게하려면 어떻게해야합니까?
which
설명서를 말한다
which returns the pathnames of the files (or links) which would be executed in the current environment, had its arguments been given as commands in
a strictly POSIX-conformant shell. It does this by searching the PATH for executable files matching the names of the arguments. It does not follow
symbolic links.
모두 /usr/local/bin
와 /usr/bin
내에있는 PATH
변수와 /usr/local/bin/pip3
기호 링크가 아닌, 그것을 실행합니다. 왜 실행되지 않습니까?
답변
명령을 실행할 때 bash
해당 실행 파일의 위치를 기억하므로 PATH
매번 다시 검색 할 필요가 없습니다 . 따라서 실행 파일을 실행하면 위치를 변경해 bash
도 여전히 이전 위치를 사용하려고 시도합니다. 이를 확인 hash -t pip3
하면 이전 위치가 표시됩니다.
실행 hash -d pip3
하면 bash에게 이전 위치를 잊어 버리고 다음에 시도 할 때 새로운 위치를 찾아야합니다.