Category Archives: Python

Running script in background on linux

If we want to run a script from terminal and be able to close the terminal without killing a script (because terminal would be a parent process, so if it dies, its children die automatically), here is the command: nohup … Continue reading

Posted in Bash, Productivity, Programming, Python, UNIX/Linux, Vim | Tagged , , | Leave a comment

Installing Scipy on Linux Red Hat

Tried to install scipy using easy_install (also pip). Installation failed with error: Atlas ( libraries not found. Instead: sudo yum install scipy works seamlessly

Posted in EC2, Machine Learning, Programming, Python | Leave a comment

Resolving import errors in Python

If you get an error saying something like ‘Can not import SomeModule”, the first thing to check is that package (which is a regular directory with added file) is in PYTHONPATH. For example, suppose you get an error when … Continue reading

Posted in Python | Leave a comment

Problems with character encoding when piping output from a python script to a file

Suppose my_unicode_string is a Python unicode string. If you get an error when you do the following: and the error is: UnicodeEncodeError: ‘ascii’ codec can’t encode character u’\xf1′ in position 9: ordinal not in range(128) To get rid of the … Continue reading

Posted in Programming, Python | Leave a comment

Running unit tests in Python

Install nose: sudo easy_install nose or: sudo pip install nose By default nose finds all directories and files that match the following regular expression: (?:^|[b_./-])[Tt]est [NOSE_TESTMATCH] I usually create a file and place my unit tests there as regular … Continue reading

Posted in Productivity, Programming, Python, UNIX/Linux | Leave a comment

Python things

How to remove a package using easy_install? sudo easy_install -m [package_name] How to start ipython notebook with interactive pylab capabilities? ipython notebook –pylab inline

Posted in Programming, Python, Uncategorized, UNIX/Linux, visualization | Leave a comment

Opening files in Python using “with” block to type less

You will type one line less if you open file using “with” block:

Posted in Programming, Python | Tagged | Leave a comment