I am not able to install easy_install in my ubuntu

i have to install Review board in ubuntu, i tried following commands but i am getting error

sudo apt-get install python-setuptools.


Reading package lists... Done
Building dependency tree       
Reading state information... Done
Package python-setuptools is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source
E: Package python-setuptools has no installation candidate

Then i tried below command but for this also i am getting error message:

apt-get upgrade

E: Could not open lock file /var/lib/dpkg/lock - open (13 Permission denied)
E: Unable to lock the administration directory (/var/lib/dpkg/), are you root?

What should i do? Please help me out!!!!!


Solution 1:

Open a terminal by pressing Ctrl+Alt+T and type the following:

sudo apt-get update
sudo apt-get upgrade
sudo apt-get install python-setuptools

Reasons behind the errors
Error1:

Package python-setuptools is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source
E: Package python-setuptools has no installation candidate 

This happens when you are trying to install a package about which APT does not have any idea. When you add software sources and then do an apt-get update your system APT's database is updated with all the packages on the repositories listed in software sources list.

Then when you try to install any package, apt checks the package name in it's database, finds it and checks the name of the repo from where it got it. It then downloads the package from that repo.
Error2:

  apt-get upgrade

    E: Could not open lock file /var/lib/dpkg/lock - open (13 Permission denied)
    E: Unable to lock the administration directory (/var/lib/dpkg/), are you root?

This means that you are not the root user.So we use sudo to execute it as root

Solution 2:

Please don't use easy_install, but try pip instead.

sudo apt-get install python-pip

Now you can use it in almost the same way as easy_install, but with better package management.

sudo pip install <pypi-package>

Solution 3:

The answer to your second issue (could not open lock file) you find here.