gpt4 book ai didi

python - 如何在未连接互联网的计算机上安装 pygame?

转载 作者:行者123 更新时间:2023-12-05 05:47:19 26 4
gpt4 key购买 nike

我正在尝试在未连接到互联网的计算机上安装 pygame 包。

(环境: windows10, python 3.9(anaconda))

所以我从www.pypi.org下载了一个“pygame-2.1.2.tar”文件然后尝试安装它

从 cmd 使用“python setup.py install”命令。

然后它会显示如下错误信息

    ===============================================================================

(base) C:\pythonpackage\pygame-2.1.2>python setup.py install


WARNING, No "Setup" File Exists, Running "buildconfig/config.py"
Using WINDOWS configuration...

Making dir :prebuilt_downloads:
Downloading... https://www.libsdl.org/release/SDL2-devel-2.0.18-VC.zip
d561079ec622b0bab5a9e02976f5d540b0622da

---
For help with compilation see:
https://www.pygame.org/wiki/CompileWindows
To contribute to pygame development see:
https://www.pygame.org/contribute.html
---

Traceback (most recent call last):
File "C:\ProgramData\Anaconda3\lib\site-packages\urllib3\connection.py", line 174, in
_new_conn
conn = connection.create_connection(
File "C:\ProgramData\Anaconda3\lib\site-packages\urllib3\util\connection.py", line 73,
in create_connection
for res in socket.getaddrinfo(host, port, family, socket.SOCK_STREAM):
File "C:\ProgramData\Anaconda3\lib\socket.py", line 954, in getaddrinfo
for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
socket.gaierror: [Errno 11002] getaddrinfo failed

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "C:\ProgramData\Anaconda3\lib\site-packages\urllib3\connectionpool.py", line 699,
in urlopen
httplib_response = self._make_request(
File "C:\ProgramData\Anaconda3\lib\site-packages\urllib3\connectionpool.py", line 382,
in _make_request
self._validate_conn(conn)
File "C:\ProgramData\Anaconda3\lib\site-packages\urllib3\connectionpool.py", line 1010,
in _validate_conn
conn.connect()
File "C:\ProgramData\Anaconda3\lib\site-packages\urllib3\connection.py", line 358, in
connect
conn = self._new_conn()
File "C:\ProgramData\Anaconda3\lib\site-packages\urllib3\connection.py", line 186, in
_new_conn
raise NewConnectionError(
urllib3.exceptions.NewConnectionError: <urllib3.connection.HTTPSConnection object at
0x00000237AF075250>: Failed to establish a new connection: [Errno 11002] getaddrinfo
failed



During handling of the above exception, another exception occurred:



Traceback (most recent call last):
File "C:\ProgramData\Anaconda3\lib\site-packages\requests\adapters.py", line 439, in
send
resp = conn.urlopen(
File "C:\ProgramData\Anaconda3\lib\site-packages\urllib3\connectionpool.py", line 755,
in urlopen
retries = retries.increment(
File "C:\ProgramData\Anaconda3\lib\site-packages\urllib3\util\retry.py", line 574, in
increment
raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='www.libsdl.org', port=443):
Max retries exceeded with url: /release/SDL2-devel-2.0.18-VC.zip (Caused by
NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x00000237AF075250>:
Failed to establish a new connection: [Errno 11002] getaddrinfo failed'))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "C:\pythonpackage\pygame-2.1.2\setup.py", line 359, in <module>
buildconfig.config.main(AUTO_CONFIG)
File "C:\pythonpackage\pygame-2.1.2\buildconfig\config.py", line 225, in main
deps = CFG.main(**kwds)
File "C:\pythonpackage\pygame-2.1.2\buildconfig\config_win.py", line 497, in main
and download_win_prebuilt.ask(**download_kwargs):
File "C:\pythonpackage\pygame-2.1.2\buildconfig\download_win_prebuilt.py", line 290, in
ask
update(x86=x86, x64=x64)
File "C:\pythonpackage\pygame-2.1.2\buildconfig\download_win_prebuilt.py", line 273, in
update
download_prebuilts(download_dir, x86=x86, x64=x64)
File "C:\pythonpackage\pygame-2.1.2\buildconfig\download_win_prebuilt.py", line 124, in
download_prebuilts
download_sha1_unzip(url, checksum, temp_dir, 1)
File "C:\pythonpackage\pygame-2.1.2\buildconfig\download_win_prebuilt.py", line 47, in
download_sha1_unzip
response = requests.get(url)
File "C:\ProgramData\Anaconda3\lib\site-packages\requests\api.py", line 75, in get
return request('get', url, params=params, **kwargs)
File "C:\ProgramData\Anaconda3\lib\site-packages\requests\api.py", line 61, in request
return session.request(method=method, url=url, **kwargs)
File "C:\ProgramData\Anaconda3\lib\site-packages\requests\sessions.py", line 542, in
request
resp = self.send(prep, **send_kwargs)
File "C:\ProgramData\Anaconda3\lib\site-packages\requests\sessions.py", line 655, in
send
r = adapter.send(request, **kwargs)
File "C:\ProgramData\Anaconda3\lib\site-packages\requests\adapters.py", line 516, in
send
raise ConnectionError(e, request=request)
requests.exceptions.ConnectionError: HTTPSConnectionPool(host='www.libsdl.org', port=443):
Max retries exceeded with url: /release/SDL2-devel-2.0.18-VC.zip (Caused by
NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x00000237AF075250>:
Failed to establish a new connection: [Errno 11002] getaddrinfo failed'))

===============================================================================

请告诉我如何在离线环境下安装pygame。

我需要你的帮助!!请~~

最佳答案

解决方案 1(对我有用;简单但棘手)

我的第一个建议是使用 .whl 文件。您可以从另一台计算机下载pygame.whl,这是另一种安装文件,并将这两个文件移动到没有网络连接的计算机上。

您可以在这里下载文件:

实际上,.whl 是一个压缩文件。您可以解压.whl文件,然后您可以看到三个文件夹:pygame、pygame-2.1.2.data和pygame-2.1.2.dist-info。你只需要 pygame 文件夹。

您可以复制该文件夹并将其粘贴到您的 python 项目中。然后你可以简单地import pygame。我刚刚尝试过这种方式,它对我有用。 (我什至尝试运行示例游戏)

解决方案2

另一个建议是从另一台电脑下载pippygame.whl,然后将这两个文件移动到没有网络连接的电脑上。

您可以在这里下载文件:

将这两个文件下载并移动到没有互联网连接的计算机后,首先解压缩 pip-22.0.3.tar.gz 并通过在 pip 文件夹中输入以下命令来安装 pip (pip还有setup.py文件):

python setup.py install

现在,pip 已经安装好了。然后,使用 .whl 文件所在的文件夹中的 pip 安装 .whl 文件。

python -m pip install pygame-2.1.2-cp39-cp39-win_amd64.whl

希望它能帮助你享受pygame

关于python - 如何在未连接互联网的计算机上安装 pygame?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/71028609/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com