在IPython中安装pygame包失败,提示pip未识别怎么办?
Hey there! That error pops up because your system can't locate the pip executable in its PATH. No worries—here are a few straightforward fixes tailored to your Windows 10 + Python 3.6.1 setup:
Quickest reliable fix: Skip the PATH issue entirely by running pip through your current Python environment. In IPython, execute this command:
!python -m pip install pygameThis works because it uses the Python interpreter you’re already using in IPython to find the pip tool directly, so you don’t need to mess with system settings right away.
If the above fails, use the full path to pip:
By default, Python 3.6 installs toC:\Python36\, and pip lives in theScriptssubfolder. Run this full path in IPython:!C:\Python36\Scripts\pip install pygameIf you installed Python for your user only (not system-wide), the path might look like
C:\Users\YourUsername\AppData\Local\Programs\Python\Python36\Scripts\pip.exe—just replaceYourUsernamewith your actual Windows username.Permanent fix: Add pip to your system PATH:
- Right-click the Start menu, select "System", then click "Advanced system settings" on the left.
- In the System Properties window, go to the "Advanced" tab and click "Environment Variables".
- Under "System variables", find the
Pathvariable, select it, and click "Edit". - Click "New" and add the path to your Python Scripts folder (e.g.,
C:\Python36\Scripts\). - Save all changes by clicking "OK" in every window, then restart IPython (or your terminal) and try
!pip install pygameagain.
Any of these methods should get pygame installed successfully!
内容的提问来源于stack exchange,提问作者Andres Cook

