6

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?

  • Does running git review work? – Chai T. Rex Feb 14 '17 at 22:46
  • No, I had to manually invoke it from /usr/local/lib/python2.7.10/bin/git-review. – ronakg Feb 14 '17 at 22:48
  • /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? – Chai T. Rex Feb 14 '17 at 22:55
  • Nope. It still goes at the same location. – ronakg Feb 14 '17 at 23:15
  • OK, I found a slightly-different option that works here. Try my answer below. – Chai T. Rex Feb 14 '17 at 23:32
7

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.

  • 1
    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 – ronakg Feb 15 '17 at 0:51
  • 1
    Sorry, I'm not seeing that, so I'm not sure how to fix it. – Chai T. Rex Feb 15 '17 at 23:00
  • 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 – ronakg Feb 15 '17 at 23:26
  • 3
    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. – Chai T. Rex Feb 15 '17 at 23:30
  • Yes exactly @chai-t-rex. – ronakg Feb 16 '17 at 18:44
3

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.

  • 1
    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) – Chai T. Rex May 31 '18 at 18:10
  • OMG! Jesus christ ubuntu – Jakobovski Nov 5 '18 at 9:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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