Help us understand the problem. What is going on with this article?

【pyenv】ubuntu16.04でのpython環境の構築

More than 3 years have passed since last update.

背景

  • tensorflowをubuntuで動かしてぇ!
  • でも、python2系のコードを使ってる!!
  • じゃあ、pyenvで複数バージョンを入れるっきゃねぇ!!!

で、『本記事に至る』

pyenvのインストール

sudo git clone git://github.com/yyuu/pyenv.git ./pyenv

[pyenv] PATHの設定

export PYENV_ROOT=$HOME/.pyenv
export PATH=$PYENV_ROOT/bin:$PATH
eval "$(pyenv init -)"

pythonのインストール

banaoh@ubuntu-dlw:~$ pyenv install 3.6.1

Downloading Python-3.6.1.tar.xz...
-> https://www.python.org/ftp/python/3.6.1/Python-3.6.1.tar.xz
Installing Python-3.6.1...

BUILD FAILED (Ubuntu 16.04 using python-build 1.1.1-1-g734e40d)

Inspect or clean up the working tree at /tmp/python-build.20170621142635.19271
Results logged to /tmp/python-build.20170621142635.19271.log

Last 10 log lines:
    ensurepip._main()
  File "/tmp/python-build.20170621142635.19271/Python-3.6.1/Lib/ensurepip/__init__.py", line 189, in _main
    default_pip=args.default_pip,
  File "/tmp/python-build.20170621142635.19271/Python-3.6.1/Lib/ensurepip/__init__.py", line 102, in bootstrap
    _run_pip(args + [p[0] for p in _PROJECTS], additional_paths)
  File "/tmp/python-build.20170621142635.19271/Python-3.6.1/Lib/ensurepip/__init__.py", line 27, in _run_pip
    import pip
zipimport.ZipImportError: can't decompress data; zlib not available
Makefile:1064: recipe for target 'install' failed
make: *** [install] Error 1
  • zlibがないと言われるのでインストール
sudo apt-get install zlib1g-dev
  • もういっちょインストール
banaoh@ubuntu-dlw:~$ pyenv install 3.6.1

Downloading Python-3.6.1.tar.xz...
-> https://www.python.org/ftp/python/3.6.1/Python-3.6.1.tar.xz
Installing Python-3.6.1...
WARNING: The Python bz2 extension was not compiled. Missing the bzip2 lib?
WARNING: The Python readline extension was not compiled. Missing the GNU readline lib?
ERROR: The Python ssl extension was not compiled. Missing the OpenSSL lib?

Please consult to the Wiki page to fix the problem.
https://github.com/pyenv/pyenv/wiki/Common-build-problems


BUILD FAILED (Ubuntu 16.04 using python-build 1.1.1-1-g734e40d)

Inspect or clean up the working tree at /tmp/python-build.20170621143006.3222
Results logged to /tmp/python-build.20170621143006.3222.log

Last 10 log lines:
                upgrade) ensurepip="--upgrade" ;; \
                install|*) ensurepip="" ;; \
        esac; \
         ./python -E -m ensurepip \
                $ensurepip --root=/ ; \
fi
Collecting setuptools
Collecting pip
Installing collected packages: setuptools, pip
Successfully installed pip-9.0.1 setuptools-28.8.0
  • 『Missing the OpenSSL lib』ってエラーが出てるので、libsshをインストール
sudo apt-get install libssl-dev
  • 『pyenv install 3.6.1』 動いた!!!

pythonのバージョンの確認、バージョンの切り替え

banaoh@ubuntu-dlw:~$ python --version
Python 2.7.12

banaoh@ubuntu-dlw:~$ pyenv global 3.6.1
banaoh@ubuntu-dlw:~$ python --version
Python 3.6.1
banaoh
Im UX engineer.
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
ユーザーは見つかりませんでした