Skip to content

Instantly share code, notes, and snippets.

@kkawamura
Last active March 28, 2020 03:05
Show Gist options
  • Save kkawamura/6090eb1af049b8d94298bb2be908d676 to your computer and use it in GitHub Desktop.
Save kkawamura/6090eb1af049b8d94298bb2be908d676 to your computer and use it in GitHub Desktop.
rebuild python env in local machine
現状
だいぶ前にpyenv, anacondaの併用がうまくできずいろいろadhocな作業したせいで、ローカルpython環境が腐ってるので直す
[~/IdeaProjects/spaas-airflow]$ which python
/usr/bin/python
[~]$ pyenv
-bash: pyenv: command not found
[~]$ cat ~/.bash_profile |grep py
#export PATH="$HOME/.pyenv/shims:$PATH"
alias python=/Library/Frameworks/Python.framework/Versions/3.7/bin/python3
# The original version is saved in .bash_profile.pysave
==========
notes:
pyenv: 複数のpython interpreterを管理するためのもの
virtualenv: Python付属の仮想環境module (module名はvenv)
pipenv: 仮想環境+αの機能があるpypa officialのlibrary
==========
-  まずpyenvでいれる
https://github.com/pyenv/pyenv#homebrew-on-macos
[~]$ brew install pyenv
Updating Homebrew...
==> Downloading https://homebrew.bintray.com/bottles/pyenv-1.2.17.high_sierra.bottle.tar.gz
==> Downloading from https://akamai.bintray.com/9a/9a4dac58fa6734a15adbef8e95a51e0495291d4644e128240f26fac23bc326a7?__gda__=ex
######################################################################## 100.0%
==> Pouring pyenv-1.2.17.high_sierra.bottle.tar.gz
🍺 /usr/local/Cellar/pyenv/1.2.17: 696 files, 2.5MB
==> `brew cleanup` has not been run in 30 days, running now...
Removing: /usr/local/Cellar/python/3.7.1... (1,098 files, 15.3MB)
Error: Could not remove python keg! Do so manually:
sudo rm -rf /usr/local/Cellar/python/3.7.1
[~]$ sudo rm -rf /usr/local/Cellar/python/3.7.1
Password:
[~]$ brew install pyenv
Updating Homebrew...
Warning: pyenv 1.2.17 is already installed and up-to-date
To reinstall 1.2.17, run `brew reinstall pyenv`
[~]$ brew reinstall pyenv
==> Reinstalling pyenv
==> Downloading https://homebrew.bintray.com/bottles/pyenv-1.2.17.high_sierra.bottle.tar.gz
Already downloaded: /Users/keisuke.kawamura/Library/Caches/Homebrew/downloads/a3e54fa86cae5ad9ef8f04b323ca3e78682c300df39409df14964d864b270850--pyenv-1.2.17.high_sierra.bottle.tar.gz
==> Pouring pyenv-1.2.17.high_sierra.bottle.tar.gz
🍺 /usr/local/Cellar/pyenv/1.2.17: 696 files, 2.5MB
==> `brew cleanup` has not been run in 30 days, running now...
Removing: /usr/local/Cellar/python/3.7.2_2... (3,966 files, 61.1MB)
Removing: /usr/local/Cellar/python/3.7.4_1... (3,998 files, 61.3MB)
Removing: /usr/local/Cellar/readline/8.0.1... (48 files, 1.5MB)
Removing: /Users/keisuke.kawamura/Library/Caches/Homebrew/readline--8.0.1.high_sierra.bottle.tar.gz... (517.0KB)
Removing: /usr/local/Cellar/sqlite/3.20.1... (11 files, 3.0MB)
Removing: /usr/local/Cellar/sqlite/3.25.3... (11 files, 3.7MB)
Removing: /usr/local/Cellar/sqlite/3.27.1... (11 files, 3.7MB)
Removing: /usr/local/Cellar/sqlite/3.29.0... (11 files, 3.9MB)
Removing: /usr/local/Cellar/xz/5.2.4... (92 files, 1MB)
Removing: /Users/keisuke.kawamura/Library/Caches/Homebrew/portable-ruby-2.6.3.mavericks.bottle.tar.gz... (9.0MB)
Removing: /Users/keisuke.kawamura/Library/Logs/Homebrew/gmp... (64B)
Removing: /Users/keisuke.kawamura/Library/Logs/Homebrew/mpfr... (64B)
Removing: /Users/keisuke.kawamura/Library/Logs/Homebrew/gawk... (64B)
Removing: /Users/keisuke.kawamura/Library/Logs/Homebrew/gettext... (64B)
Pruned 1 symbolic links and 2 directories from /usr/local
[~]$ pyenv versions
* system (set by /Users/keisuke.kawamura/.pyenv/version)
==============
[~]$ pyenv install 3.7.5
python-build: use openssl@1.1 from homebrew
python-build: use readline from homebrew
Downloading Python-3.7.5.tar.xz...
-> https://www.python.org/ftp/python/3.7.5/Python-3.7.5.tar.xz
Installing Python-3.7.5...
python-build: use readline from homebrew
Installed Python-3.7.5 to /Users/keisuke.kawamura/.pyenv/versions/3.7.5
=============
[~]$ pyenv global 3.7.5
[~]$ pyenv version
3.7.5 (set by /Users/keisuke.kawamura/.pyenv/version)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment