본문 바로가기
언어 정리/python_설치

python 버전 변경

by 알 수 없는 사용자 2022. 8. 17.

https://codechacha.com/ko/change-python-version/

 

Ubuntu에서 Python 버전을 변경하는 방법

우분투를 설치하면 파이선2.7이 설치되어있습니다. 리눅스의 Alternatives를 이용하면 python 버전을 쉽게 변경하고 관리할 수 있습니다. 우분투에 파이썬2.7과 파이썬3.5 버전을 모두 설치하고, 특정

codechacha.com


Update-alternatives로 파이썬 버전 등록 및 변경

먼저 파이썬을 등록하기 전에 이미 등록된 것이 있는지 확인해야 합니다.

update-alternatives --config python 옵션은 python 버전을 변경하는 옵션입니다. 만약 아래 error 로그처럼 설정된 것이 없다고 한다면 아무것도 등록된 것이 없다는 의미입니다.

$ sudo update-alternatives --config python
update-alternatives: error: no alternatives for python

update-alternatives --install [symbolic link path] python [real path] number 명령어는 실행파일을 등록하는 명령어입니다.

아래와 같이 입력하면 2.7과 3.6버전이 update-alternatives에 등록됩니다. 물론 파이썬 2.7과 3.6이 설치되어 있어야 합니다. 만약 설치위치가 저와 다르다면 자신의 PC에 설치된 path로 변경하셔야 합니다.

$ sudo update-alternatives --install /usr/bin/python python /usr/bin/python2.7 1
$ sudo update-alternatives --install /usr/bin/python python /usr/bin/python3.6 2

그리고 update-alternatives --config python을 다시 입력하면 등록한 파이썬 버전을 선택하는 메뉴가 나옵니다.

$ sudo update-alternatives --config python
There are 2 choices for the alternative python (providing /usr/bin/python).

  Selection    Path                Priority   Status
------------------------------------------------------------
* 0            /usr/bin/python3.6   2         auto mode
  1            /usr/bin/python2.7   1         manual mode
  2            /usr/bin/python3.6   2         manual mode

Press <enter> to keep the current choice[*], or type selection number: 2

원하는 메뉴의 번호를 입력하고 파이썬 버전을 확인해 보세요. 파이썬의 link를 따라가보면 alternatives 명령어로 설정한 /usr/bin/python3.6를 가리킵니다.

$ python --version
Python 3.6.3

$ ls -al /usr/bin/python
lrwxrwxrwx 1 root root 24  4월 18 19:28 /usr/bin/python -> /etc/alternatives/python

$ ls -al /etc/alternatives/python
lrwxrwxrwx 1 root root 18  9월  2 13:59 /etc/alternatives/python -> /usr/bin/python3.6

 


https://askubuntu.com/questions/1331391/how-do-you-install-pip-for-python3-9-4

 

How do you install pip for python3.9.4?

I haven't found a way to install pip for python3.9 . When I run the command sudo apt install python3-pip it installs pip for pythpn3.8, not 3.9. If I try to use sudo apt install python3.9-pip it gi...

askubuntu.com

 

 

pip 버전 변경  [ python 3.8 pip -->> python 3.9 pip ]

 

You can install pip for python3.9 using get-pip.py as the official documentation as well as the github page describes it:

curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
python3.9 get-pip.py

 


 

 

 

 

 

 

'언어 정리 > python_설치' 카테고리의 다른 글

ubuntu16.04 에 python3.8 소스설치  (0) 2022.07.22

댓글