Table of Contents

How to install Python 3.5, Python 3.7 and Anaconda distribution on Centos

How to install python 3.5 on Centos

yum install gcc
cd /usr/src
wget https://www.python.org/ftp/python/3.5.6/Python-3.5.6.tgz

tar -xvf Python-3.5.6.tgz
cd Python-3.5.6

For better optimizations run make with --enable-optimizations, this will run Unit tests

./configure --enable-optimizations
make

If you dont want to make it python3.5 default then do make install; otherwise make altinstall

make install

Type Python 3.5, and you should see the Python3.5 shell

python3.5

How to install python 3.7 on Centos

lets install python 3.7 version now

cd ..
wget https://www.python.org/ftp/python/3.7.3/Python-3.7.3.tgz
cd Python-3.7.3.tgz
tar -xvf Python-3.7.3.tgz
cd Python-3.7.3
./configure --enable-optimizations
make
make install

I got following error , if you dont see the below error that means you are good.

#ModuleNotFoundError: No module named '_ctypes'

If you see the above error, install following library and make configure, make and make install commands again

yum install libffi-devel
./configure --enable-optimizations
make
make install

You might also run in to following error...

Ignoring ensurepip failure: pip 9.0.1 requires SSL/TLS

To fix, install following...

yum install zlib-devel bzip2-devel sqlite sqlite-devel openssl-devel

Now let us try installing again.

make install

How To Install Anaconda 3 On Centos

Let us also install Conda python package manager

wget https://repo.anaconda.com/archive/Anaconda3-2019.07-Linux-x86_64.sh
chmod +x Anaconda3-2019.07-Linux-x86_64.sh
./Anaconda3-2019.07-Linux-x86_64.sh

Let us add Anaconda to System Path.

export PATH=$PATH:/home/anaconda3/bin/

If you don't want to auto initialize anaconda on login set following

conda config --set auto_activate_base false

How To Create Python 3 Virtual Environment Using Anaconda3

let us create a python 3.7 environment now using conda create -n yourenvname python=x.x anaconda

conda create -n condapy373 python=3.7.3 anaconda

To activate Conda env

conda init bash
conda activate condapy373

To update Conda, you can run following command...

conda update -n base -c defaults conda

That's it you have Conda with python 3.7 installed now

Related Topics:

Python Scrapy Tutorial Python Scrapy

Related Posts