15
15

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

CentOS7にPython3(Anaconda3)をインストール

Last updated at Posted at 2017-01-14

環境

・CentOS7
・pyenv + Anaconda

参考

[pyenv]https://github.com/yyuu/pyenv

導入

sudo yum install git -y
git clone https://github.com/yyuu/pyenv.git ~/.pyenv
echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.bash_profile
echo 'export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.bash_profile
echo 'eval "$(pyenv init -)"' >> ~/.bash_profile
source ./.bash_profile

##Anaconda

導入できるAnacondaを確認

pyenv install --list | grep anaconda

###Anacondaを導入

pyenv install anaconda3-4.1.1

Python2系=anaconda2~
Python3系=anaconda3~

###Errorになった

Downloading Anaconda3-4.1.1-Linux-x86_64.sh...
-> https://repo.continuum.io/archive/Anaconda3-4.1.1-Linux-x86_64.sh
Installing Anaconda3-4.1.1-Linux-x86_64...

BUILD FAILED (CentOS Linux 7 using python-build 1.0.6-13-g4d96271)

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

Last 10 log lines:
/tmp/python-build.20170114112223.16911 ~
/tmp/python-build.20170114112223.16911/Anaconda3-4.1.1-Linux-x86_64 /tmp/python-build.20170114112223.16911 ~
PREFIX=/home/centos/.pyenv/versions/anaconda3-4.1.1
tar (child): bzip2: exec 不能: そのようなファイルやディレクトリはありません
tar (child): Error is not recoverable: exiting now
tar: Child returned status 2
tar: Error is not recoverable: exiting now

###Errorの原因らしきbzip2を導入

sudo yum install bzip2 -y

###再度Anacondaを導入

pyenv install anaconda3-4.1.1

###うまくいった

$pyenv versions
* system (set by /home/centos/.pyenv/version)
  anaconda3-4.1.1

###Pythonの導入

pyenv install 3.6.0

###Errorになった

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

BUILD FAILED (CentOS Linux 7 using python-build 1.0.6-13-g4d96271)

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

Last 10 log lines:
checking for --with-universal-archs... no
checking MACHDEP... linux
checking for --without-gcc... no
checking for --with-icc... no
checking for gcc... no
checking for cc... no
checking for cl.exe... no
configure: error: in `/tmp/python-build.20170114122724.27883/Python-3.6.0':
configure: error: no acceptable C compiler found in $PATH
See `config.log' for more details

###GCCをインストールする

sudo yum install gcc -y

###まだError

Downloading Python-3.6.0.tar.xz...
<中略>
zipimport.ZipImportError: can't decompress data; zlib not available
make: *** [install] エラー 1

###Zlibをインストールする

sudo yum install zlib -y

結果、この辺を対応しないといけなかった。

CentOS/Fedora 21 and below:
FIXME: you may need to install xz to build some CPython version

yum install gcc zlib-devel bzip2 bzip2-devel readline-devel sqlite sqlite-devel openssl-devel
15
15
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
15
15

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?