0

When I install anything with setup.py or with pip on OS X, it is installed only into an older Python version. What is the best way to solve this? Here is written that a solution is to modify the first line of /usr/local/share/python/pip, but I do not know how to access that file.

1
  • What Python version? 2 vs 3? or 2.6 vs 2.7? Commented May 28, 2014 at 21:00

1 Answer 1

2

Try: /path/to/your/python -m pip install {yourlib}

Long answer:

For more information on what's going on, you can run which python or which pip. This shows you exactly which python/pip is being run. Even if you install another pip for another python, running the new pip may not install the package on the new python. If you look at the output from pip, you may see something like:

$ pip install pyodbc
Requirement already satisfied (use --upgrade to upgrade): pyodbc in /some/other/python/path/pyodbc-3.0.7-py2.7-linux-x86_64.egg
Cleaning up...

If your previous python path (echo $PYTHONPATH) can be seen by your new pip, or if it's linked in ~/.local, then pip will find the package and think it's already installed. If you uninstall the package on the old version, then the reinstall should install to the right location if you're using the right pip.

Response to follow-up question in comments - When pip isn't found by bash:

There are quite a few solutions:

  1. The above will work
  2. If you want to be able to type pip, then putting alias pip='/path/to/your/python -m pip' or simply alias pip='/path/to/your/new/pip' will work
  3. Uninstalling and reinstalling the new python/pip package should put pip in your default namespace. Likely your old pip was around when you first installed, so it didn't overwrite.
  4. Play with your $PATH. The most complicated, but probably the cleanest answer. I have a ~/bin/ in my path, to which I add symlinks for anything I want in my standard path.
Sign up to request clarification or add additional context in comments.

3 Comments

And, if that doesn't work, you'll need to install pip for that instance of Python. Generally, each Python instance you have needs its own version of pip.
I have the new pip, and I uninstalled pip on the old version, but the pip of the new version is not found, since it is not the default version. What is the best solution?
added four solutions to your new question. Note that 1, 2, and 4 assume you know where your new pip was installed to.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.