Installing Python into your home directory

Sometimes we may need a newer Python version than the one installed into our station, and the Linux distribution does not provide the last release in its repositories. We could get rid the installed Python packages and make a new installation from the source code. However, various OS applications make use of the default Python version installed, thus there is a risk of breaking some applications or services of the system in the case of overriding the Python provided by the package management system used, yum or apt, for example.

Thus, we may install Python into the local user directory, and let the default Python installation intact.

Another reason to do this is to have multiple Python environments when developing or debugging old Python scripts.

The following commands were tested into an Ubuntu 16.04 amd64 docker container.

Install prerequisites for downloading and compiling Python from source:

# apt install xz-utils wget gcc make \
  libssl-dev libffi-dev zlib1g-dev

If you are running CentOS 7,  install the following packages:

# yum groupinstall -y "development tools"

# yum install -y \
  libffi-devel \
  zlib-devel \
  bzip2-devel \
  openssl-devel \
  ncurses-devel \
  sqlite-devel \
  readline-devel \
  tk-devel \
  gdbm-devel \
  db4-devel \
  libpcap-devel \
  xz-devel \
  expat-devel

Create a folder for the new Python installation, download, and extract the source code. In this example, I used the hidden directory $HOME/.python.

mkdir $HOME/.python
cd $HOME/.python
wget https://www.python.org/ftp/python/3.7.0/Python-3.7.0.tar.xz
tar Jxvf Python-3.7.0.tar.xz
cd Python-3.7.0

Compile and install Python.

./configure --prefix=$HOME/.python --enable-optimizations
make
make install

Next, we need to edit $HOME/.profile , and $HOME/.bashrc files to add the Python’s bin directory to $PATH.

export PATH="$HOME/.python/bin:$PATH"
export PYTHONPATH="$HOME/.python"

Then we can reload the current session by doing:

source $HOME/.profile

Now we have multiple python installations on our system. If we type ‘python’ and press TAB twice we can see:

roger@9e65d2dd5598:~$ python
python python2.7 python3-config python3.5m python3.7-config python3.7m-config
python2 python3 python3.5 python3.7 python3.7m python3m

So, to run the new python REPL, we must enter:

roger@9e65d2dd5598:~$ python3.7
Python 3.7.0 (default, Sep 26 2018, 22:06:04)
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>

Pip also is referred by its version:

roger@9e65d2dd5598:~$ pip3.7

Usage:
pip3.7 <command> [options]

When developing executable python scripts for this environment, the bash shebang used must be like:

#!/usr/bin/env python3.7

Delete the Python source code and compilation directory:

rm -fr $HOME/.python/Python-3.7.0*

 

This article is adapted from the solution presented in http://thelazylog.com/install-python-as-local-user-on-linux/.

LPIC-02 pass

Dear Candidate,

LPI ID: LPI000116018

Congratulations on obtaining your LPIC-2 certification.

Exams

Exam Date Grade Details
101 2006-08-05 00:00:00 pass details
102 2006-08-05 00:00:00 pass details
201 2010-10-21 15:17:57 pass details
202 2010-10-22 15:31:35 pass details

No dia 19 de Dezembro vou fazer a prova 301, necessária para a Senior Level Linux Professional (LPIC-3).

Overview of Tasks: to pass LPIC-3 “Core” someone should:

  • Have several years experience with installing and maintaining Linux on a number of computers for various purposes
  • Have integration experience with diverse technologies and operating systems
  • Have professional experience as, or training for, an enterprise level Linux professional. (Including having experience as a part of another role)
  • Know advanced and enterprise levels of Linux administration including installation, management, security, troubleshooting and maintenance
  • Be able to use open source tools to measure capacity planning and troubleshoot resource problems
  • Have professional experience using LDAP to integrate with Unix services and Windows services, including Samba, PAM, email, Active Directory
  • Be able to plan, architecture, design, build and implement a full environment using Samba and LDAP as well as measure the capacity planning and security of the services
  • Be able create scripts in Bash or Perl or has knowledge of at least one system programming language (such as C)

Como a prova praticamente aborda integração com OpenLDAP estou tomando como material de estudos o livro “OpenLDAP – Uma abordagem integrada” de Clodonil Honório Trigo, que a meu ver aborda todos os tópicos descritos na sessão objetivos detalhados do da prova 301. Como adição tenho lido também o material disponibilizado em http://www.rootkit.nl/files/book_lpic-3_301.html.

Coincidentemente, no momento estou trabalhando em um projeto de centralização, integração e single SignOn da base de usuários entre vários sistemas e serviços.

Para o exame LPIC-02 utilizei o livro Certificação Linux LPI: Nível 2 Exames 201 e 202 de Steven Pritchard, O’Reilly. Um bom livro que abordou bem todos os tópicos cobrados no meu exame.