Mac上pip安装pygame报错问题处理

@[TOC] Mac上pip安装pygame报错问题处理

问题描述

执行命令: ~]$ python -m pip install --user pygame
报错如下:

ERROR: Could not find a version that satisfies the requirement pygame (from versions: none)
ERROR: No matching distribution found for pygame

解决方案

  1. 打开终端
  2. 输入命令:pip install whell
Defaulting to user installation because normal site-packages is not writeable
Requirement already satisfied: wheel in /Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9/site-packages (0.37.0)
WARNING: You are using pip version 21.2.4; however, version 23.3.1 is available.
You should consider upgrading via the '/Library/Developer/CommandLineTools/usr/bin/python3 -m pip install --upgrade pip' command.
  1. 输入命令:pip install pygame
Defaulting to user installation because normal site-packages is not writeable
WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ReadTimeoutError("HTTPSConnectionPool(host='pypi.org', port=443): Read timed out. (read timeout=15)")': /simple/pygame/
WARNING: Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ReadTimeoutError("HTTPSConnectionPool(host='pypi.org', port=443): Read timed out. (read timeout=15)")': /simple/pygame/
ERROR: Could not find a version that satisfies the requirement pygame (from versions: none)
ERROR: No matching distribution found for pygame
WARNING: You are using pip version 21.2.4; however, version 23.3.1 is available.
You should consider upgrading via the '/Library/Developer/CommandLineTools/usr/bin/python3 -m pip install --upgrade pip' command.

5.接下来我们把警告引号里面的内容复制下来执行就可以了:
/Library/Developer/CommandLineTools/usr/bin/python3 -m pip install --upgrade pip

Defaulting to user installation because normal site-packages is not writeable
Requirement already satisfied: pip in /Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9/site-packages (21.2.4)
WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ReadTimeoutError("HTTPSConnectionPool(host='pypi.org', port=443): Read timed out. (read timeout=15)")': /simple/pip/
WARNING: Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ReadTimeoutError("HTTPSConnectionPool(host='pypi.org', port=443): Read timed out. (read timeout=15)")': /simple/pip/
WARNING: Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ReadTimeoutError("HTTPSConnectionPool(host='pypi.org', port=443): Read timed out. (read timeout=15)")': /simple/pip/
Collecting pip
  Downloading pip-23.3.1-py3-none-any.whl (2.1 MB)
     |████████████████████████████████| 2.1 MB 430 kB/s 
Installing collected packages: pip
  WARNING: The scripts pip, pip3, pip3.11 and pip3.9 are installed in '/Users/zhangxiuzeng/Library/Python/3.9/bin' which is not on PATH.
  Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
Successfully installed pip-23.3.1
WARNING: You are using pip version 21.2.4; however, version 23.3.1 is available.
You should consider upgrading via the '/Library/Developer/CommandLineTools/usr/bin/python3 -m pip install --upgrade pip' command.

6.再执行命令:pip install pygame

Defaulting to user installation because normal site-packages is not writeable
WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ReadTimeoutError("HTTPSConnectionPool(host='pypi.org', port=443): Read timed out. (read timeout=15)")': /simple/pygame/
Collecting pygame
  Downloading pygame-2.5.2-cp39-cp39-macosx_10_9_x86_64.whl.metadata (13 kB)
Downloading pygame-2.5.2-cp39-cp39-macosx_10_9_x86_64.whl (12.8 MB)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 12.8/12.8 MB 5.4 MB/s eta 0:00:00
Installing collected packages: pygame
Successfully installed pygame-2.5.2
  1. import pygame 验证是否安装成功
  • 8
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
### 回答1: 当您在安装pygame时,可能会遇到各种错误。其中一种常见的错误是“pip install pygame报错”。这可能是由于以下原因之一: 1. 您的计算机上没有安装pygame。 2. 您的计算机上已经安装pygame,但是版本不兼容。 3. 您的计算机上缺少一些必要的依赖项。 为了解决这个问题,您可以尝试以下步骤: 1. 确保您的计算机上已经安装pip。如果没有,请先安装pip。 2. 确认您的计算机上已经安装pygame。如果没有,请使用以下命令安装pygamepip install pygame 3. 如果您已经安装pygame,但是仍然遇到错误,请尝试升级pygame到最新版本: pip install --upgrade pygame 4. 如果您仍然遇到错误,请检查您的计算机上是否缺少必要的依赖项。您可以在pygame的官方网站上找到这些依赖项,并按照说明进行安装。 希望这些步骤可以帮助您解决“pip install pygame报错”的问题。 ### 回答2: 当我们在使用pip安装Pygame时,有时候会遇到报错的情况,其中会出现各种不同的错误信息,导致无法完成Pygame安装。 下面给大家列出了一些可能出现的错误信息以及相应的解决方法: 1. ERROR: Command errored out with exit status 1 这个错误信息通常是由于编译器在安装时出错了,可以尝试安装Microsoft Visual C++ Build Tools来解决,也可以尝试安装Python的开发环境。 2. ERROR: Could not find a version that satisfies the requirement pygame 这个错误信息通常是由于Pygame的版本与Python版本不兼容,需要安装与所使用的Python版本相对应的Pygame版本。 3. ERROR: Command "python setup.py egg_info" failed with error code 1 这个错误信息通常是由于Python的setuptools没有安装或版本过老,需要先安装最新版本的setuptools,然后再去安装Pygame。 除此之外,还有一些其他的可能性导致Pygame安装失败的原因,比如系统环境变量不正确,网络连接不稳定等等,需要根据实际情况进行排查处理。 总体来说,解决Pygame安装报错需要对系统运行环境、Python版本、Pygame版本等方面进行全面分析,然后根据不同情况选择相应的解决方案,以保证Pygame能够正常安装和使用。 ### 回答3: 首先需要强调的是,pip install pygame报错问题可归为两类:环境问题和版本问题。 1. 环境问题 常见的pip install pygame报错问题大多是由于环境问题引起的。例如,缺少相关的依赖库、python版本不兼容等等。 解决此类问题需要针对性地查找错误信息,根据错误原因指导调整相关环境。下面我们列举两种典型的错误信息及对应解决方案。 错误信息一:ERROR: Failed building wheel for pygame 原因分析:由于缺失相关依赖库或未安装wheel,导致pip无法为pygame构建wheel,因而出现此报错。 解决方案: ① 安装wheel:使用pip install wheel 命令安装wheel。 ② 安装相关依赖库:根据错误信息提示,安装相关的依赖库。比如,apt-get install python3-dev 针对的就是出现pygame安装错误时缺少python3-dev依赖库的情况。 错误信息二:ERROR: pygame-1.9.1release-candidate.win32-py3.2.msi is not a supported wheel on this platform 原因分析:此类报错大多是因为python版本不支持所要安装pygame版本,导致无法安装成功。 解决方案: ① 升级python版本:安装pygame兼容的最新python版本。 ② 安装对应pygame版本:找到支持当前python版本的pygame版本,并安装。 2. 版本问题 另外,部分pip install pygame报错也与版本问题有关。一些较老的pygame版本可能已经无法兼容当前python环境,因此需要进行升级或换用新版本。 解决方案: 可以到官网下载最新的pygame版本,或查找其他可用的pygame版本进行安装,以解决版本兼容问题。 总之,pip install pygame报错问题是一种常见的python开发问题,我们应该注重查找错误信息并根据具体情况灵活处理,从而确保pygame包顺利安装

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值