Debian Linux를 설치할 때 설치 프로세스에서 사용 가능한 여러 Python 버전을 동시에 제공할 수 있으므로 시스템에 여러 Python 실행 가능 바이너리가 있게 됩니다. 다음 명령을 사용하여 ls
시스템에서 사용 가능한 Python 바이너리를 확인할 수 있습니다.
$ ls /usr/bin/python*
/usr/bin/python /usr/bin/python2 /usr/bin/python2.7 /usr/bin/python3 /usr/bin/python3.4 /usr/bin/python3.4m /usr/bin/python3m
기본 Python 버전 정보를 보려면 다음 명령을 실행하십시오.
$ python --version
Python 2.7.8
1. 사용자에 따라 Python 버전을 수정합니다.
특정 사용자의 Python 버전을 수정하려면 해당 사용자의 홈 디렉터리에 alias
별칭을 생성하면 됩니다. 사용자의 ~/.bashrc
파일을 열고 새 별칭 정보를 추가하여 기본 Python 버전을 수정합니다.
alias python='/usr/bin/python3.4'
위 작업이 완료되면 다시 로그인하거나 .bashrc
파일을 다시 로드하여 작업을 적용하세요.
$ . ~/.bashrc
현재 Python 버전을 확인하세요.
$ python --version
Python 3.4.2
2. 시스템 수준에서 Python 버전 수정
update-alternatives
전체 시스템의 Python 버전을 변경하는 데 사용할 수 있습니다 . 루트로 로그인하고 먼저 사용 가능한 모든 Python 대체 버전 정보를 나열하십시오.
# update-alternatives --list python
update-alternatives: error: no alternatives for python
위에 표시된 것과 같은 오류 메시지가 나타나면 대체 버전의 Python이 update-alternatives
명령에서 인식되지 않았다는 의미입니다. 이 문제를 해결하려면 python2.7
및 를 python3.4
포함 하도록 대체 목록을 업데이트해야 합니다 .
# update-alternatives --install /usr/bin/python python /usr/bin/python2.7 1
update-alternatives: using /usr/bin/python2.7 to provide /usr/bin/python (python) in auto mode
# update-alternatives --install /usr/bin/python python /usr/bin/python3.4 2
update-alternatives: using /usr/bin/python3.4 to provide /usr/bin/python (python) in auto mode
--install
옵션은 기호 링크를 생성하기 위해 여러 매개변수를 사용합니다. 마지막 매개변수는 이 옵션의 우선순위를 지정합니다. 대체 옵션을 수동으로 설정하지 않으면 우선순위가 가장 높은 옵션이 선택됩니다. 이 예에서는 /usr/bin/python3.4
우선순위를 2로 설정하므로 update-alternatives
명령이 자동으로 이를 기본 Python 버전으로 설정합니다.
# python --version
Python 3.4.2
다음으로, 사용 가능한 Python 대체 버전을 다시 나열합니다.
# update-alternatives --list python
/usr/bin/python2.7
/usr/bin/python3.4
이제부터 아래 명령을 사용하여 언제든지 나열된 대체 Python 버전 간에 전환할 수 있습니다.
# update-alternatives --config python
# python --version
Python 2.7.8
3. 대체 버전 제거
Python의 대체 버전이 시스템에 더 이상 존재하지 않으면 update-alternatives
목록에서 삭제할 수 있습니다. 예를 들어 목록에서 python2.7 버전을 제거할 수 있습니다.
# update-alternatives --remove python /usr/bin/python2.7
update-alternatives: removing manually selected alternative - switching python to auto mode
update-alternatives: using /usr/bin/python3.4 to provide /usr/bin/python (python) in auto mode
경로: http://linuxconfig.org/how-to-change-from-default-to-alternative-python-version-on-debian-linux
이 기사는 원래 LCTT 에서 편집되었으며 Linux China 에서 자랑스럽게 출시되었습니다 .
"Celebrateing More Than Years 2"의 불법 복제 리소스가 npm에 업로드되어 npmmirror가 unpkg 서비스 를 중단해야 했습니다. Microsoft의 중국 AI 팀은 수백 명의 사람들을 모아 미국으로 떠났습니다. 프론트엔드 시각화 라이브러리와 Baidu의 유명한 오픈 소스 프로젝트 ECharts - Fish 사기꾼을 지원하기 위한 "going to the sea"는 TeamViewer를 사용하여 398만 개를 전송했습니다! 원격 데스크톱 공급업체는 무엇을 해야 합니까? Zhou Hongyi: Google은 시간이 얼마 남지 않았습니다. 모든 제품을 오픈소스로 만드는 것이 좋습니다. 한 유명 오픈소스 회사의 전직 직원이 소식을 전했습니다. 부하 직원의 도전을 받은 후 기술 리더는 분노했습니다. Google은 Android 가상 머신에서 ChromeOS를 실행하는 방법을 보여주었습니다. 여기서 time.sleep(6)은 어떤 역할을 합니까? 마이크로소프트, 중국 AI 팀이 "미국을 위해 준비 중"이라는 루머에 대응 사무용 소프트웨어의 마트료시카 같은 충전에 대한 인민일보 온라인 논평: "세트"를 적극적으로 해결해야만 미래를 가질 수 있다