User Tools

Site Tools


notes:install-python-3.4-and-mysql-connector-on-debian-7-wheezy

Use Python 3.4 + MySQL Connector on Debian 7 Wheezy

Debian 7 Wheezy ships with Python 3.2 (a bit outdated) and mysql-connector-python 2.0 works only with Python 3.3 o later versions. However, you can setup your own Python 3.4 virtual environment and run your script inside it (main source: extellisys.com [1])

The necessary libs to build the optional modules can be istalled with

sudo apt-get install build-essential libncurses5-dev libncursesw5-dev libreadline6-dev libgdbm-dev libsqlite3-dev liblzma-dev libbz2-dev tk-dev zlib1g-dev libssl-dev

May be you would also need (are they really needed? to be confirmed)

sudo apt-get install libdb5.1-dev libexpat1-dev 

Now compile and install Python with

cd /tmp
wget https://www.python.org/ftp/python/3.4.2/Python-3.4.2.tar.xz  
tar -xf Python-3.4.2.tar.xz
cd Python-3.4.2
./configure --prefix=/usr/local/opt/python-3.4.2
make
sudo make install
cd /tmp
sudo rm -rf Python-3.4.2

Setup a Virtual Environment for you project

cd ~/myproject/
/usr/local/opt/python-3.4.1/bin/pyvenv virtualenv-3.4.2

Install mysql-connector-python 2.0 from source

source virtualenv-3.4.2/bin/activate
pip3.4 install http://dev.mysql.com/get/Downloads/Connector-Python/mysql-connector-python-2.0.2.tar.gz

Run your python3 project with

source virtualenv-3.4.2/bin/activate
python3 myproject.py

[1] http://www.extellisys.com/articles/python-on-debian-wheezy

notes/install-python-3.4-and-mysql-connector-on-debian-7-wheezy.txt · Last modified: 2014/11/29 01:22 by admin