OSX系统安装pip后仍提示‘pip: command not found’问题求助
Hey Andrew, let's work through why your pip command isn't being recognized even though easy_install says it's already installed. Here are some straightforward fixes to get you up and running with MoviePy:
方法1:用Python模块方式调用pip(最稳妥)
Instead of typing just pip, use Python's built-in module system to invoke it—this avoids any PATH-related confusion and ensures you're using the pip tied to your active Python version:
sudo python -m pip install moviepy
This should directly trigger the pip installation for MoviePy without needing to hunt for the pip executable.
方法2:手动定位pip的路径
If the above doesn't work, let's find where pip is actually installed:
First, run this command to check if your system can locate pip:
which pipOr since your pip is for Python 2.7, try:
which pip2If this returns nothing, pip's directory isn't in your system's PATH.
Next, search for pip's exact location:
find /usr/local/bin -name pipYou'll likely see something like
/usr/local/bin/pipas the result. Use this full path to run the installation:sudo /usr/local/bin/pip install moviepy
方法3:将pip目录添加到系统PATH(永久生效)
To make the pip command work directly in future terminal sessions, add its directory to your PATH:
Temporary fix (only for current terminal window):
export PATH=/usr/local/bin:$PATHNow test with
pip --version—it should show up! Then you can runsudo pip install moviepyas intended.Permanent fix:
Edit your shell configuration file (either~/.bash_profilefor Bash or~/.zshrcfor Zsh) and add this line at the bottom:export PATH=/usr/local/bin:$PATHSave the file, then restart your terminal or run
source ~/.bash_profile(orsource ~/.zshrc) to apply the changes. From now on,pipwill be recognized whenever you open a terminal.
额外建议
OSX's built-in Python can sometimes have permission quirks. For long-term projects, consider using a virtual environment (like virtualenv or venv) to manage dependencies without needing sudo—but for getting MoviePy installed quickly, the above steps should do the trick.
内容的提问来源于stack exchange,提问作者Andrew

