Basic profiling in Python

So just do the following to see which functions take the most time:

 
import cProfile, pstats

    pr = cProfile.Profile()
    pr.enable()

    #... some interesting code    
           
    pr.disable()
    sortby = 'time'
    pstats.Stats(pr ).strip_dirs().sort_stats(sortby).print_stats()
Advertisements

Adding libraries to python path in bash

First of all, check the current python path:

echo $PYTHONPATH 

Then, check the current .bashrc file. For example, use:

gedit .bashrc &

Add the following lines to the end of the file:

export PYTHONPATH=$HOME/"location of library"

Note that sometimes you will need to add the above to the .profile file instead.
Cheers!