Install Python 3.6 on Ubuntu 14.04 and 16.04 LTS

A regular Ubuntu release comes up with 9 months of support, except the LTS (Long Term Support) versions.  Ubuntu 14.04 and 16.04 being the LTS are still widely in use at production level. Being a Python developer the first thing I need to on having a fresh Ubuntu 14.04, or 16.04 machine is update Python. Ubuntu 14.04 has Python 3.4 and 16.04 comes with Python 3.5. This blog post is about installing Python 3.6 on your Ubuntu 14.04, or 16.04 LTS.

Step 0 – Install the pre-requisites (optional)

The following step are optional, as to cater post-installation issues i.e. “zipimport.ZipImportError: can’t decompress data; zlib not available” for the missing zlib-dev, and also preparing environment for Python development.
$ sudo apt-get update
$ sudo apt-get install build-essential libpq-dev libssl-dev openssl libffi-dev zlib1g-dev
$ sudo apt-get install python3-pip python3-dev

Latest Ubuntu 17.10 already comes with Python 3.6 installed, can verify by executing python3.

For Ubuntu 16.10 and 17.04

Python 3.6 is available for install via the main repository, all you have to do is
$ sudo apt-get update
$ sudo apt-get install python3.6

For Ubuntu 14.04 and 16.04 LTS

Python 3.6 is not available for direct install, you have to either add a repository and install, or simply download and install. You can verify if Python 3.6 is available for direct install
$ apt-cache search python3.6

Method 1 – using PPA

PPA (Personal Package Archives) allows contributor to upload and share Ubuntu source packages to be built and published at an apt repository by Launchpad. There has been always an open debate regarding the PPA red flags while using a PPA, main important point to consider is, who made the PPA. For Python 3.6 J Fernyhough’s PPA, is widely used and reliable.
$ sudo add-apt-repository ppa:jonathonf/python-3.6
$ sudo apt-get update
$ sudo apt-get install python3.6

Method 2 – Download and configure

$ wget https://www.python.org/ftp/python/3.6.3/Python-3.6.3.tgz
$ tar -xvf Python-3.6.3.tgz
$ cd Python-3.6.3
$ sudo ./configure --enable-optimizations
If above configure ends up with no errors, execute the following commands to complete the installation of Python 3.6
$ sudo make -j8
$ sudo make install

Verification

Execute the python3.6
nahmed@localhost:~$ python3.6
Python 3.6.3 (default, Oct  6 2017, 08:44:35)
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>

Creating virtualenv using Python 3.6 (optional)

Given that you have more than one Python 3 versions installed, and need to use Python 3.6 for your project. Best practice is to create a virtual environment using Python 3.6

Install virtualenv

$ sudo pip3 install virtualenv

Create virtualenv

$ virtualenv -p /usr/bin/python3.6 ~/virtualenvs/venv_devopspy
$ source virtualenvs/venv_devopspy/bin/activate
(venv_devopspy) nahmed@localhost:~$

Allow remote connections to PostgreSQL

PostgreSQL (aka Postgres), is an open-source SQL relational database management system (RDBMS). These RDBMS are the key component for the majority of all the web sites and web applications, providing an efficient way to persist, organize, and access information.
The last blog was “Install PostgreSQL 9.6 on Ubuntu 14.04, or 16.04 LTS” . By default postgresql allows connections only from the localhost (127.0.0.1) i.e. any service on the same machine, only. So, a necessary step in PostgreSQL installation is to allow remote connections.

Continue reading “Allow remote connections to PostgreSQL”

Install PostgreSQL 9.6 on Ubuntu 14.04 or 16.04 LTS

PostgreSQL (aka Postgres), is an open-source SQL relational database management system (RDBMS). These RDBMS are the key component for the majority of all the web sites and web applications, providing an efficient way to persist, organize, and access information.
In the blog, I’ll demonstrate, how to install Postgres 9.6 for Ubuntu 14.04, 16.04 LTS.

Step 1: Add Postgresql repository

$ sudo add-apt-repository "deb http://apt.postgresql.org/pub/repos/apt/ $(lsb_release -sc)-pgdg main"
$ wget -q -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -

Continue reading “Install PostgreSQL 9.6 on Ubuntu 14.04 or 16.04 LTS”

Install Node.js, npm, and Angular on CentOS 7.x

Node.Js

Node.js is a cross-platform, open-source JavaScript library for server-side, contrary to previous practice of using JavaScript primarily for client-side scripting by embedding the scripts in a webpage’s HTML. Node.js provides asynchronous I/O capability out of the box with it’s event-driven architecture. Node.js has been adopted by major corporations, including IBM, LinkedIn, Microsoft, Netflix, Paypal, GoDaddy, Walmart, Cisco systems, a lot more.

npm

NPM is the package management utility for the JavaScript programming language i.e. Node.js, Angular. It provides a command-line client for consuming and distributing the JavaScript modules from the remote registry . Easiest (most common way) to install npm is installing the Node.js, it has it as the default package manager. Currently npm registry has 347,184 packages, and there’s no approval process for submission of the package, you have to check the number of downloads and depending packages as a assurance of a good quality module. For more you can check the npm page.

Continue reading “Install Node.js, npm, and Angular on CentOS 7.x”

Apache Spark and PySpark on CentOS/RHEL 7.x

What is Apache Spark

You may have noticed, wherever there is a talk about big data the name Apache Spark eventually comes up, in simplest words it’s a large-scale data processing engine. Apache Spark is a fast data processing framework with provided APIs to connect and perform big data processing. Spark being the largest open-source data processing engine, has been adopted by large companies – Yahoo, eBay, Netflix, have massive scale Spark deployments, processing multiple petabytes of data on clusters of over 8,000 nodes.
Apache Spark can be started as a standalone cluster (which we’ll be doing for this tutorial), or using Mesos or YARN as cluster managers. Spark can work with data from various sources, AWS S3, HDFS, Cassandra, Hive (structured data), HBase, or any other Hadoop data source. Above all what makes Spark high in-demand is the included libraries MLib, SQL and DataFrames, GraphX, and Spark Streaming, to cater the main data processing use-cases, such that users can combinely use all these libraries in the same application.

Continue reading “Apache Spark and PySpark on CentOS/RHEL 7.x”

Ruby Kernel for Jupyter Notebook

Jupyter notebooks are nice way to keep your code, diagrams, documentation together, mostly in a single file, which is also executable i.e. can run/interpret your code in it, and also have the result saved as it is. Here’s blogpost for installing Jupyter Notebook – today I’ll share how to use Ruby kernel with Jupyter Notebook i.e. executing Ruby code inside the notebooks.
To create notebooks that can execute Ruby code we need to integrate Ruby kernel, the 3 simple steps are:
  • Install Jupyter
  • Install Ruby
  • Install iruby

Continue reading “Ruby Kernel for Jupyter Notebook”

Install latest Ruby version using rbenv

Ruby is a dynamic, open source programming language with a focus on simplicity and productivity. Yukihiro “Matz” Matsumoto created it in the mid-1990s, using his influence from other prpgramming languages i.e. Perl, Ada, Lips, Eiffel, and Smalltalk. Ruby was released in 1995. Like Python (released few years earlier), ruby also has dynamic typing and implicit memory management

Continue reading “Install latest Ruby version using rbenv”

Install Jupyter Notebook

What is Jupyter Notebook

If you’re a Python developer, or someone who has to interact with Python, you may be hearing or seeing the term Jupyter Notebook quite lot, while reading articles, or looking for some solution on-line.
The Jupyter Notebook is an open-source web application that allows you to create and share documents that contain live code, equations, visualizations and explanatory text. Uses include: data cleaning and transformation, numerical simulation, statistical modeling, machine learning and much more.

Continue reading “Install Jupyter Notebook”

Anaconda on CentOS 7.x

What is Anaconda

Anaconda is a free open-source Python distribution (as well as R programming language), intended for large-scale data processing and  analysis, and scientific computing. Anaconda Python  distribution is manged and developed by Continuum Analytics.
Anaconda (“Anaconda Distribution”) is a free, easy-to-install package manager, environment manager, Python distribution, and collection of over 720 open source packages with free community support. Hundreds more open source packages and their dependencies can be installed with a simple “conda install [packagename]”. It’s platform-agnostic, can be used on Windows, OS X and Linux. Or even easier.

Continue reading “Anaconda on CentOS 7.x”

conda VS pip

I decided to write this post, as I myself when for the first time tried to use conda (the package manager for Anaconda Python distribution, the first question was in what ways conda is better then pip, and so why one should think of preferring condo over the de-facto pip. Here I have put a comprehensive post about ‘getting started with conda’ i.e. what extra condo can offer.

A short comparison

pip
  • Can only be used for Python packages.
  • The supported package manger by the Python foundation, hence widely used.
conda
  • Handles library dependencies even outside Python i.e. packages for C libraries, or R packages, or really anything.
  • Supports virtual environment out of the box.
  • Developed to be used with Anaconda Python distribution, though can be used with the standard Python distribution – but highly not recommended.

Continue reading “conda VS pip”