Upgrade to python3 on CentOS

While working on machine learning, I faced issues to use NLTK 3. Event some libraries need python3 to run. I use alibaba cloud with centos6. Here are the steps to follow to install python 3.x and pip3

First, install minimum necessary tools:

$ sudo yum install yum-utils

Then using yum-builddep, set up a necessary build environment for python3 and install missing dependencies. The following command will automatically take care of that.

$ sudo yum-builddep python

Now download the latest python3 (e.g., python 3.5) from https://www.python.org/ftp/python/

$ curl -O https://www.python.org/ftp/python/3.5.0/Python-3.5.0.tgz

Finally, build and install python3 as follows. The default installation directory is /usr/local. If you want to change this to some other directory, pass “–prefix=/alternative/path” parameter to configure before running make.

$ tar xf Python-3.5.0.tgz
$ cd Python-3.5.0
$ ./configure
$ make
$ sudo make install

This will install python3, pip3, setuptools as well as python3 libraries on your CentOS system.

$ python3 –version

alias python=’/usr/local/bin/python3.5′

Method Two: Install Python3 from EPEL Repository

The latest EPEL 7 repository offers python3 (python 3.4 to be exact). Thus if you are using CentOS 7 or later, you can easily install python3 by enabling EPEL repository as follows.

$ sudo yum install epel-release

Then install python 3.4 and its libraries using yum:

$ sudo yum install python34

Note that this will not install matching pip. To install pip and setuptools, you need to install them separately as follows.

$ curl -O https://bootstrap.pypa.io/get-pip.py
$ sudo /usr/bin/python3.4 get-pip.py

Method Three: Install Python3 from Software Collections (SCL)

Another way to install python3 is via enabling Software Collections (SCL) repository. The SCL repository is available for CentOS 6.5 or later, and the latest SCL offers python 3.3. Once you enable the SCL repository, go ahead and install python3 as follows.

$ sudo yum install python33

To use python3 from the SCL, you need to enable python3 on a per-command basis as follows.

$ scl enable python33 <command>

You can also invoke a bash shell with python3 enabled as the default Python interpreter:

$ scl enable python33 bash
Source: http://ask.xmodulo.com/install-python3-centos.html
How to use pip to use virtualenv for packages

python3 -m virtualenv pyeztask/

Enable .htaccess directive in httpd CentOS

Make sure AccessFileName set to .htaccess

Search httpd.conf for AccessFileName directive. It defines name of the distributed configuration file:

grep -i AccessFileName httpd.conf

Make sure users are allowed to use .htaccess file

What you can put in these files is determined by the AllowOverride directive. This directive specifies, in categories, what directives will be honored if they are found in a .htaccess file. If this directive is set to None, then .htaccess files are completely ignored. In this case, the server will not even attempt to read .htaccess files in the filesystem.

grep -i AllowOverride httpd.conf

When this directive is set to All, then any directive which has the .htaccess Context is allowed in .htaccess files: AllowOverride All

Save and close the file. Restart httpd:

service httpd restart

Leave a Reply

Your email address will not be published. Required fields are marked *