Skip to content

Instantly share code, notes, and snippets.

@joyk50
Last active June 8, 2020 08:16
Show Gist options
  • Select an option

  • Save joyk50/6befc46bf6c857f78931e3eef4f32606 to your computer and use it in GitHub Desktop.

Select an option

Save joyk50/6befc46bf6c857f78931e3eef4f32606 to your computer and use it in GitHub Desktop.
centos7 python 설정 관련

centos7 python 설정 관련

레드햇 계열에서는 파이썬 설치시 pyenv가 갑이다.

sudo yum install @development zlib-devel bzip2 bzip2-devel readline-devel sqlite sqlite-devel openssl-devel xz xz-devel libffi-devel findutils
curl https://pyenv.run | bash
echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.zshrc
echo 'export PATH="$PYENV_ROOT/shims:$PYENV_ROOT/bin:$PATH"' >> ~/.zshrc
sudo chmod -R 775 /.pyenv/shims /.pyenv/versions

alternatives 설정

  • ubuntu 계열에서는 update-alternatives 가 redhat 계열에서는 alternatives 임.
  • 예시: OS 내부 코드들이 python2에 의존되어 있어서 python 링크는 되도록 안건드는 것을 추천
sudo alternatives --install /usr/bin/python python /usr/bin/python2.7 1
sudo alternatives --install /usr/bin/python3 python /usr/bin/python3.6 2
sudo alternatives --config python 2
sudo alternatives --install /usr/local/bin/pip pip /usr/local/bin/pip2.7 1
sudo alternatives --install /usr/local/bin/pip3 pip /usr/local/bin/pip3.6 2
sudo alternatives --config pip 2

sudo 명령어 할 때 명령어 못찾는 경우

sudo vi /etc/sudoers
# /usr/local/bin 추가해 줄 것
Defaults secure_path = /.pyenv/shims:/.pyenv/bin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment