Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I had python 2.6 in my server to begin with. Then I downloaded python 2.7 and installed using make and make altinstall. When I try just python in the terminal it opens up python 2.7 but sudo python opens up 2.68. all the commands like virtualenv pip use python 2.68

share|improve this question

migrated from stackoverflow.com May 27 '13 at 10:05

This question came from our site for professional and enthusiast programmers.

    
Probably because $PATH differs between you and root. – Aya May 26 '13 at 16:02
up vote 6 down vote accepted

Because sudo XYZ basically means "run XYZ as some other user (root by default)". That user may have a different set of environment variables, including $PATH.

To confirm this, compare the output of the following:

env | grep PATH
sudo env | grep PATH
share|improve this answer
    
Thanks. That seems to be the case. How do I ensure the path are same? – user1743992 May 26 '13 at 16:53

Check the outputs of which python and sudo which python, they should be different. If so, check your $PATH for root and your normal user as noted by others.

share|improve this answer

As was suggested, check your path. If that does not work, check your .bashrc in your home directory. A standard way to use a different python version is to use an alias for python (assigned to /usr/local/bin/python2.7 for example) in the .bashrc

share|improve this answer

You must log in to answer this question.