본문 바로가기
정나우/코드

우분투 18.04 python3 버전만 바꾸기

by 정_나우 2023. 8. 22.

배경

 

ROS는 파이썬 2.7에서 잘 작동

 

YOLO 작동 시키기 위해서는 파이썬 3.7이상이 필요

but, 컴퓨터에는 파이썬3.6.9가 기본으로 설치되어 있음

 

python -V

를 입력했을 때는 2.7

 

python3 -V

를 입력했을 때는 3.8이 나오도록 만들어야 함


해결

1. python -V로 확인하는 python 버전 바꾸기

 

1-1. 등록하기

sudo update-alternatives --install /usr/bin/python python /usr/bin/python3.6 3

코드 마지막에 3.6은 원하는 버전 3은 우선 순위 →각자 기호에 맞게 변경해서 쓰면 됨

 

1-2. 바꾸기

sudo update-alternatives --config python

 

2. python3 -V로 확인하는 python3 버전 바꾸기

 

2-1. 등록하기

sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.8 1

2-2. 바꾸기

sudo update-alternatives --config python3

 

댓글