pip install is not installing executables in /usr/local/bin

26,339

Solution 1

I had to remove the pip package that was installed by apt.

sudo apt remove python-pip

And then install pip again according to instructions on their website - https://pip.pypa.io/en/stable/installing/.

wget https://bootstrap.pypa.io/get-pip.py
sudo python get-pip.py

Looks like pip from Ubuntu's default repository is not same as one distributed by pypi.

Solution 2

Open a terminal and run:

pip uninstall git-review
sudo pip uninstall git-review
sudo pip install --prefix /usr/local git-review
git review --version

The last command should output something like git-review version 1.25.0.

Share:
26,339

Related videos on Youtube

ronakg
Author by

ronakg

Updated on September 18, 2022

Comments

  • ronakg
    ronakg over 1 year

    I recently setup a new Ubuntu 16.04.2 machine. I'm trying to install some python packages, but all the packages are getting installed at /usr/local/lib/python2.7.10/bin instead of /usr/bin or /usr/local/bin.

    Installing collected packages: git-review
    
      changing mode of /usr/local/lib/python2.7.10/bin/git-review to 755
    Successfully installed git-review-1.25.0
    

    What's the problem here?

    • Chai T. Rex
      Chai T. Rex over 7 years
      Does running git review work?
    • ronakg
      ronakg over 7 years
      No, I had to manually invoke it from /usr/local/lib/python2.7.10/bin/git-review.
    • Chai T. Rex
      Chai T. Rex over 7 years
      /usr/bin shouldn't be used because it's used only for dpkg/Apt packages. Does pip install --install-option="--prefix=/usr/local/bin" git-review put it in /usr/local/bin and have it working correctly?
    • ronakg
      ronakg over 7 years
      Nope. It still goes at the same location.
    • Chai T. Rex
      Chai T. Rex over 7 years
      OK, I found a slightly-different option that works here. Try my answer below.
  • ronakg
    ronakg over 7 years
    That did work, but now I'm getting another error. $ git review Traceback (most recent call last): File "/usr/local/bin/git-review", line 7, in <module> from git_review.cmd import main ImportError: No module named git_review.cmd
  • Chai T. Rex
    Chai T. Rex over 7 years
    Sorry, I'm not seeing that, so I'm not sure how to fix it.
  • ronakg
    ronakg over 7 years
    Actually I removed the installed pip using sudo apt remove python-pip and then reinstalled pip according to instructions here - pip.pypa.io/en/stable/installing
  • Chai T. Rex
    Chai T. Rex over 7 years
    Its use is cautioned there: Be cautious if you're using a Python install that's managed by your operating system or another package manager. get-pip.py does not coordinate with those tools, and may leave your system in an inconsistent state.
  • ronakg
    ronakg over 7 years
    Yes exactly @chai-t-rex.
  • Chai T. Rex
    Chai T. Rex almost 6 years
    You can do the last part without a temporary file with sudo python <(wget -O- https://bootstrap.pypa.io/get-pip.py 2>/dev/null)
  • Jakobovski
    Jakobovski over 5 years
    OMG! Jesus christ ubuntu