How to Install mysql-connector for Python

For several months Python mysql-connector has been broken when attempting a install from pip.  In truth I’ve only tried Python 3, CentOS 6/7 and Fedora 21; in fact, this could be a more wide spread.  The simple solution is to install an earlier version.  The purpose of this post is to be a quick reminder of which is the most recent working version!



How to handle Python 3 Fabric exceptions with a Decorator

Python’s Fabric module is an easy and efficient way for task based automation.  I use it to automate the installation of VoIP phone systems on CentOS 6/7.  In a nut shell, Fabric executes shell commands over SSH.  It also can be used to automate local tasks.  The purpose of this article is to highlight the basic process of capturing Fabric exceptions(try/except) using a wrapper function called a decorator.  A few well placed decorators can save lot of time coding the same thing over and over(like capturing a specific error). 

Most of you in the know about Python/Fabric probably  will find my examples trivial, but I had to dig to find the Fabric exception environment variable.  I’m sure it’s somewhere on the Fabric site… but I gave up after 30 minutes.  So hopefully you will find this post useful either way!

If you need help installing Python3, pip3 and Fabric please refer to my previous post.

Goals of this Post:

  • create a simple Fabric function that creates a directory
  • create a Fabric exception
  • create Decorator for adding exception handling

Lets start with a basic fabfile.py: 



How to Install Python 3 and pip 3 for CentOS 6

CentOS 6 doesn’t have native support for Python 3 and corresponding module management tool ‘pip’.  I prefer pip for managing my Python modules.  On CentOS 7 there is a specific yum package for pip(Python 2.7) and pip3(Python 3.4) respectively. However on COS 6 we must install the ‘epel repository’ to get Python 3.4 and there is no specific package for installing ‘pip 3’.  This tutorial is a friendly reminder for myself and others on how to install Python3 & pip3 for CentOS 6.x.

Goals of this post:

  • Install Python 3.4
  • Install pip3
  • Upgrade pip3


Written by mattb in: Linux,Python,Scripts | Tags: , , , , ,