问题
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.
回答1:
Try with this:
pip3 install package-name
This works for me!
回答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.
回答3:
Can you go to python shell and type import pip
? If that works, then it means the pip
package is installed, but there is no command-line script/program available.
In my computer, the command-line pip
program is actually a python script in itself, and is located in /usr/local/bin/
, which is in my PATH
. Below are the contents of my pip
script.
#!/usr/bin/python
import re
import sys
from pip import main
if __name__ == '__main__':
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
sys.exit(main())
This is a dirty trick. What you could do is to create a new file called pip
in your /usr/local/bin/
directory (or similar for OSX) and copy the above lines into it.
sudo touch /usr/local/bin/pip # create a new empty file called "pip"
# ... open the file in your favorite editor, copy the above contents and save the file
sudo chmod +x /usr/local/bin/pip # make it executable
The first line in the file (#!/usr/bin/python
), called "Shebang", points to the program that should execute this file when you run it on your command-line. You should put the path to the python program in your computer over there.
回答4:
I Tried Everything and Nothing was working for me and after that, I tried
sudo apt install python3-pip
and It worked perfectly💯
来源:https://stackoverflow.com/questions/49628139/pip-command-not-found-after-installed-it