python - 如何在 OSX 中将 pygame 安装到我的 vs 代码项目中?
问题描述
我想将 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.
解决方案
最好的解决方案是创建一个虚拟环境,以便您可以安装到该环境中,而不是全局安装 Python。但如果这不是一个选项,那么错误消息中的建议是有道理的:使用--user
:
pip install --user pygame
但请确保pip
安装您在 VS Code 中选择的 Python 解释器,而不是其他已安装的 Python 副本。如果您不确定,最安全的方法是指定要安装的 Python 解释器:
/path/to/python -m pip install --user pygame
推荐阅读
- machine-learning - 获取 ValueError:无法将字符串转换为浮点数:设置回归拟合时出现“2,600”错误
- javascript - 基于嵌套数组重新组合对象数组
- django - 在 Django 上加载静态文件的问题
- excel - Excel 女士:从属下拉列表仅适用于第一行
- python-3.x - Python PyQt5 QTableWidget contextMenuEvent setStyleSheet 子菜单背景颜色
- symfony - Symfony 嵌入表单集合不显示表单
- azure-devops - 我正在尝试将提要连接到 azure devops 中,出现错误 TF400813: The user is not authorized to access this resource
- java - 应用程序监听器
导致 java.lang.Exception: 异常只是为了在 Spring Boot 应用程序中提供堆栈跟踪 - python - ValueError:检查输入时出错:预期 conv2d_input 有 4 个维度
- reactjs - 在 React 中,render() { return()} 与 class extends component{render(){}} 之间声明 'const' 或 'let' 有什么区别?