Linux Ask!

Linux Ask! is a Q & A web site specific for Linux related questions. Questions are collected, answered and audited by experienced Linux users.

Mar 072010
 

Installing Python modules with easy_install

Answer:

Install Python modules cannot be easier with easy_install.

To use easy_install, you can use apt-get to install the "python-setuptools" package

# sudo apt-get install python-setuptools

Then you can use easy_install to install the module you want, e.g. pymongo

# sudo easy_install pymongo

Mar 012010
 

How to perform syntax check for Python program

Answer:

Assume you have a simple Python script hello.py, you want to perform syntax check. You can use the following method

# python -c 'import hello'

Traceback (most recent call last):
  File "", line 1, in 
  File "hello.py", line 1
    echo "Hello, World!"

If there is any syntax error, it will prompt out to the screen.

Mar 012010
 

How to remove install CPAN modules?

Answer:

1. Copy the script below, e.g. remove_module.pl

#!/usr/bin/perl -w 

use ExtUtils::Packlist; 
use ExtUtils::Installed; 

$ARGV[0] or die "Usage: $0 Module::Name\n"; 

my $module = $ARGV[0]; 

my $inst = ExtUtils::Installed->new(); 

foreach my $item (sort($inst->files($module))) { 
    print "Removing $item\n"; 
    unlink $item; 
} 

my $packfile = $inst->packlist($module)->packlist_file(); 
print "Removing $packfile\n"; 
unlink $packfile; 

2. Execute the script to remove module, e.g. MongoDB

# perl remove_module.pl MondoDB