July 30, 2013

Installing Python 2.6 and PyBluez on Rpi (or any Debian-based Linux Distro)

My experiment on running the simple server based on Python 2.6 and PyBluez works well in Windows along with the App I've written. I was able to send data from the Android App and the server was able to receive the data and display it.

Implementing native Bluetooth socket on Rpi sent me to a dead end where I could not figure out why it doesn't work and lack of resources to resolve the problem. Although packaged in within the more updated version of Python (Python 3.3), little documentations have been made on it.

On Rpi, the App shown that connection has been made with the server and data has been successfully sent, but none of those are indicated on the server that I ran. Weird? Yes. I have decided to try writing the server with the older Python 2.6 and PyBluez to test if it works.


Installing Python 2.6 in Linux:
1. Download Python 2.6 from here
2. Go to the containing directory (use "cd" command to navigate).
3. Decompress the .tar.gz by using
    "tar -xzf Python-2.6.6.tar.gz"
4. Go to the decompressed folder "cd Python-2.6.6"
5. Issues these following command
   "./configure
  make
  sudo make install
"


Installing PyBluez in Linux:
1. Download PyBluez from here
2. Go to the containing directory
3. Decompress the .tar.gz by using
    "tar -xzf PyBluez-0.18.tar.gz"
4. Go to the decompressed folder "cd PyBluez-0.18"
5. Still in the shell, run "sudo python2.6 setup.py install

(Note that we run the script using "python2.6" and not "python". "python" will refer to the default installed python which could be Python2.7 or Python 3 which we don't want to use for now. Issuing "python2.6" will ensure that we run our scripts using Python2.6 instead.)

Update: You might get an error that says Python.h is missing. Python.h is a header file written in C++. It is used by gcc to build applications. You need to install a package called python-dev. This package includes header files, a static library and development tools for building Python modules. To install this package, enter: "sudo apt-get install python2.6-dev" targeting our Python2.6You might also need to install bluetooth header (bluetooth.h). Enter "apt-get install libbluetooth-dev". After these two headers are installed, now you can proceed to installing PyBluez.

Update: It seems that writing the server with Python2.6 and PyBluez gave me the same result. My next try will be writing the server on another language. The problem could be on Python's implementation on Bluetooth with Rpi.

No comments:

Post a Comment

Write a reply