2016年8月8日 星期一

[RR Python] Matplotlib with VNC

while using VNC with matplotlib, I found that there is error "_tkinter.tclerror couldn't connect to display 1.0"

the solution is here 

quote as below

===
Write these few lines to etc/sudoers*:
Defaults    env_reset
Defaults    secure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
Defaults    env_keep += "DISPLAY"
Defaults    env_keep += "XAUTHORITY"
And these few lines to ~/.bashrc:
if [ -z "$XAUTHORITY" ]; then
    if [ -e $HOME/.Xauthority ]; then
        export XAUTHORITY=$HOME/.Xauthority;
    fi;
fi
===

2016年5月26日 星期四

[RR Python] Autocompletion in Python Interpreter

search for a while and found here

follows are capture and credit to Stefano Palazzo



down voteaccepted
First, create a new file called .pythonstartup.py in your home directory. Put the following script in it:
try:
    import readline
except ImportError:
    print("Module readline not available.")
else:
    import rlcompleter
    readline.parse_and_bind("tab: complete")
The parentheses around the string ensure that it works with both Python 2 and Python 3.
Every time the interactive interpreter is started, it executes a script defined in $PYTHONSTARTUP, if there is one. To set it to execute the above script, type
export PYTHONSTARTUP=".pythonstartup.py"
You should write this line to your .bashrc or .bash_profile file, so that it's automatically executed when a new shell is started.

2016年3月6日 星期日

[RR Python] PyBluez Example, beacon_scan.py beacon.py executing problem

While running PyBluez examples, beacon_scan.py beacon.py, at the first time, there is error messages

    from gattlib import *ImportError: No module named gattlib

Apparently the module gattlib which is not installed causes this error.

However, as I tried to install gattlib by pip, another error raises

    Package glib-2.0 was not found in the pkg-config search path.
    Perhaps you should add the directory containing `glib-2.0.pc'
    to the PKG_CONFIG_PATH environment variable
    No package 'glib-2.0' found
So I did 'apt-get install glib-2.0' and the error was removed. But...

    In file included from src/gattservices.cpp:12:0:
    src/gattlib.h:11:33: fatal error: boost/python/list.hpp: No such file or directory
     #include <boost/python/list.hpp>
                                     ^
    compilation terminated.

Yes, gattlib is still not installed because missing of boost. It's important to know that apt-get cannot find 'boost'. We have to install 'libboost-all-dev' instead.



After those above, 'beacon.py' and 'beacon_scan.py' are ready to go!






2016年1月14日 星期四

[RR Python] PyBluez Example, rfcomm-server.py Problem with running RFCOMM server on PORT_ANY

I always get error "_bluetooth.error: (98, 'Address already in use')" while running PyBluez example rfcomm-server.py,

The code piece is:
server_sock=BluetoothSocket( RFCOMM )
server_sock.bind(("",PORT_ANY))
server_sock.listen(1)

it's apparent that the listening port is occupied by someone since I can run it successfully if changing the port number from PORT_ANY to 2 or 3.

GoogleCodeExporter explains the issue, which might be caused by pnat server. Per discussion1 and discussion2, disabling pnat plugin in bluetooth config works. BEWARE that restart bluetooth service somehow doesn't work though, I have to reboot to make it enabled

in  /etc/bluetooth/main.confadd/append DisablePlugins = pnat
There is still question that HOW TO FIGURE OUT WHICH SERVICE/SERVER OCCUPIED WHAT PORT!!!