问题描述:在mac中安装了两个版本的Python,终端默认Python2.7, launchpad中可以找到Python3.6.应用程序中存在Python2.7和Python3.6的文件夹解决:首先安装pip,安装过程中感觉系统自带Python中存有pip,可能也不需要安装。如需安装,可在“https://pip.pypa.io/en/stable/installing/”中另存“get-pip.py”为get-pip.py文件,进入python运行安装。
如果出现一下错误:
Installing collected packages: pip, wheel
Exception:
Traceback (most recent call last):
File "/var/folders/96/fc61zjqn5jsccvt3t82_81v40000gn/T/tmppz5FTP/pip.zip/pip/basecommand.py", line 215, in main
status = self.run(options, args)
File "/var/folders/96/fc61zjqn5jsccvt3t82_81v40000gn/T/tmppz5FTP/pip.zip/pip/commands/install.py", line 342, in run
prefix=options.prefix_path,
File "/var/folders/96/fc61zjqn5jsccvt3t82_81v40000gn/T/tmppz5FTP/pip.zip/pip/req/req_set.py", line 784, in install
**kwargs
File "/var/folders/96/fc61zjqn5jsccvt3t82_81v40000gn/T/tmppz5FTP/pip.zip/pip/req/req_install.py", line 851, in install
self.move_wheel_files(self.source_dir, root=root, prefix=prefix)
File "/var/folders/96/fc61zjqn5jsccvt3t82_81v40000gn/T/tmppz5FTP/pip.zip/pip/req/req_install.py", line 1064, in move_wheel_files
isolated=self.isolated,
File "/var/folders/96/fc61zjqn5jsccvt3t82_81v40000gn/T/tmppz5FTP/pip.zip/pip/wheel.py", line 345, in move_wheel_files
clobber(source, lib_dir, True)
File "/var/folders/96/fc61zjqn5jsccvt3t82_81v40000gn/T/tmppz5FTP/pip.zip/pip/wheel.py", line 316, in clobber
ensure_dir(destdir)
File "/var/folders/96/fc61zjqn5jsccvt3t82_81v40000gn/T/tmppz5FTP/pip.zip/pip/utils/__init__.py", line 83, in ensure_dir
os.makedirs(path)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/os.py", line 157, in makedirs
mkdir(name, mode)
OSError: [Errno 13] Permission denied: '/Library/Python/2.7/site-packages/pip-9.0.1.dist-info'
在terminal中输入:
sudo xcode-select --install
下载完X-code的命令行工具,再输入
python shouei$ python get-pip.py
而后,直接输入“sudo pip install pygame”,进入Python2.7的Pygame安装模式。“sudo pip3 install pygame”则进入Python3.6的Pygame安装模式。
安装完毕,可分别进入相关Python检测安装状态。输入“import pygame”,出现“>>>”则成功安装!