我想将pygame包添加到我的vs代码项目中。 我正在使用OSX,并且安装了pip,python和pygame。
但是我无法安装它。我阅读了控制台日志,但不知道如何解决:
DEPRECATION: Python 2.7 will reach the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 won't be maintained after that date. A future version of pip will drop support for Python 2.7.
Collecting pygame
Using cached https://files.pythonhosted.org/packages/96/e6/a0e790157db7dc6b62192d09a93085bcb2a5261ee45ddc4d6d225ecc4a4d/pygame-1.9.6-cp27-cp27m-macosx_10_11_intel.whl
Saved ./pygame-1.9.6-cp27-cp27m-macosx_10_11_intel.whl
Successfully downloaded pygame
choehyomin-ui-MacBookPro:~ choihyomin$ pip install pygame
DEPRECATION: Python 2.7 will reach the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 won't be maintained after that date. A future version of pip will drop support for Python 2.7.
Collecting pygame
Using cached https://files.pythonhosted.org/packages/96/e6/a0e790157db7dc6b62192d09a93085bcb2a5261ee45ddc4d6d225ecc4a4d/pygame-1.9.6-cp27-cp27m-macosx_10_11_intel.whl
Installing collected packages: pygame
ERROR: Could not install packages due to an EnvironmentError: [Errno 13] Permission denied: '/Library/Python/2.7/site-packages/pygame'
Consider using the `--user` option or check the permissions.
答案 0 :(得分:0)
最好的解决方案是创建一个虚拟环境,以便您可以在其中安装而不是在全局安装Python。但是,如果那不是一个选择,那么错误消息中的建议就很有意义:使用--user
:
pip install --user pygame
但是请确保为您在VS Code中选择的Python解释器安装了pip
,而不是其他安装的Python副本。如果不确定,最安全的方法是指定要安装的Python解释器:
/path/to/python -m pip install --user pygame