0

I have changed my username recently on Ubuntu 16.04 LTS. I have also changed the home folder. Now that I try to install any package using pip, I get this error.

bash: /home/hasnain/Downloads/Programs/123456/bin/pip: /home/hassaan/Downloads/Programs/123456/bin/python: bad interpreter: No such file or directory

Where hasnain is my new username while the old username was hassaan. pip runs fine with sudo, but the packages installed using sudo pip can only be run using sudo.
How do I use pip without sudo?

nAiN
  • 5
  • @karel thanks. But this isn't a permanent fix, right? I want to be able to use it on system. – nAiN Sep 05 '17 at 08:10
  • In a way a it kind of is a permanent fix because installing with pip locally without sudo doesn't always work because pip or some other package isn't up to date to the latest version and installing with pip inside a Python virtual environment reduces the probability of failed Python package installations while adding an additional layer of security. If you make a mistake you can always fix it no matter what by deleting the Python virtual environment and rebuilding it. – karel Sep 05 '17 at 08:13

1 Answers1

0

First of all, you can use apt or apt-get to install pip. You will probably need to uninstall your locally installed version of pip if you do this.

You can run the following commands to install pip:

sudo apt update
sudo apt install python-pip

To install python3-pip, use the following command:

sudo apt install python3-pip

Instead of using a virtual environment, you can install stuff with the --user flag.

Here is an example of how to install youtube-dl using this method:

pip install --user youtube-dl

Here is an example of how to update youtube-dl using the same method:

pip install --user --upgrade youtube-dl
mchid
  • 43,546
  • 8
  • 97
  • 150