Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

Hi I'm new to ubuntu and I have the following problem:

I'm aware that ubuntu comes with a python version, but I'm running in a web host and I don't have the sudo command and I only have access to my /home/user

I installed python 2.7.5 on my home, but when I try to do the easy_install command, it goes to /usr/bin/python

How can I do to use the python installed on my /home and not the one in the /usr/bin/?

share|improve this question

1 Answer 1

up vote 2 down vote accepted

Your best bet is to use an alias. Open your ~/.bash_aliases file and type the following:

alias python='/path/to/python/in/your/home/directory'

with the '. For example, if your python binary file is /home/user/Documents/bin/python, the alias would be:

alias python='/home/user/Documents/bin/python'

This would not break existing application, since they would continue to use whatever version is /usr/bin/python or /usr/bin/python3 and you would use the python stored in your home directory.

For easy_install to install modules to a specific directory, you can use the --install-dir option together with the $PYTHONPATH environment variable. To do this, do the following:

export PYTHONPATH='/home/user/python/lib/

and then

easy_install --install-dir /home/user/python/lib/ <module_to_install>

or whatever path you want to give to easy_install to install the modules.

share|improve this answer
    
Thanks, this solve my problem, but another one appeared because I would like to use easy_install and this is still going to /user/bin but I'm not sure if the version I have installed of python comes with easy_install, anyway the easy_install it is still going to /usr/bin –  ocespedes Apr 15 at 22:41
    
@ocespedes: Edited my answer to reflect that. –  i08in Apr 15 at 22:56
    
Is it /home/user/python_lib/ or /home/user/python/lib/. You have used both in your answer. Moreover, we may also create an alias for easy_install so that we do not need to type that long command everytime. –  Aditya Apr 16 at 9:09
    
@Aditya: I didn't mean to introduce an ambiguity but the user could create and add any arbitrary folder name. Thanks for pointing that out. –  i08in Apr 16 at 9:12

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.