pip command not found after installed it

37,426

Solution 1

Try with this:

pip3 install package-name

This works for me!

Solution 2

Yes, it's a mess. Today, your best option is to leave the ageing, OS-provided version of Python (all the stuff in /Library/Python and similar) alone and start fresh.

It looks like you've already done this (since you have an executable at /usr/bin/python) but if not, the easiest way to get Python 2 is to use Homebrew. Install Homebrew using the instructions on the website and then use it to install Python:

brew install python@2

Python 2.7.9+ comes with pip already, but if you've ended up with an older version then use python itself and get-pip.py to install pip (instead of easy_install, which is deprecated):

curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
python get-pip.py

Note that get-pip.py includes a copy of pip in order to install pip effectively. Yes, things are that bad.

Finally, note that Python 2 will be end of life in less than 6 months. If you have the luxury, consider skipping straight to Python 3. Then it's as easy as:

brew install python

because pip3 comes with python3 since version 3.4. Homebrew manages to handle the installation of both Python 2 and Python 3 without conflict.

Note this procedure is different on every operating system and every month or two. But at least it should get you going for the foreseeable future.

Share:
37,426
Admin
Author by

Admin

Updated on October 16, 2020

Comments

  • Admin
    Admin over 3 years

    I'm stuck with an issue. I have a Python script that I would like to run on my OSX but seems that I crossed on many issues.

    To run the script I should have both Python and Moviepy installed.

    To install Moviepy I used this command:

    sudo pip install moviepy
    

    The response was:

    sudo: pip: command not found
    

    So I tried to install pip, with the command:

    sudo easy_install pip
    

    And got this answer:

    Searching for pip
    Best match: pip 9.0.1
    Processing pip-9.0.1-py2.7.egg
    pip 9.0.1 is already the active version in easy-install.pth
    
    Using /Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg
    Processing dependencies for pip
    Finished processing dependencies for pip
    

    I tried to run again the

    sudo pip install moviepy
    

    but I still got that issue. What I should do?

    UPDATE:

    not sure on OSX, but can u try pip3 – Rehan Azher 23 mins ago

    sudo pip3 install moviepy
    Password:
    sudo: pip3: command not found
    

    It seems that pip is not in your path, but as long as Python can find it: sudo python -m pip install moviepy should do it. Check your $PATH env. variable, tho. – zwer 14 mins ago

    sudo python -m pip install moviepy
    /usr/bin/python: No module named pip
    

    UPDATE2

    A good option for you is to consider installing pip using one of OSX's sources, like the apt program in Debian-based distributions, rather than easy_install. – Shiva 4 hours ago

    sudo apt install moviepy
    Password:
    Unable to locate an executable at "/Library/Java/JavaVirtualMachines/jdk1.8.0_131.jdk/Contents/Home/bin/apt" (-1)
    

    No idea why everyone keeps getting stuck on this. You have a fundamental decision to make when using Python. You either run Python 2.7 that Apple ships and which is ancient and doesn't have pip or you use homebrew and install Python3 and pip3 and put /usr/local/bin at the start of your PATH. But don't try a mixture of the two. – Mark Setchell 3 hours ago

    Tried to install homebrew but it cannot find the package moviepy that I am looking for.