将 Pygame 与 PyPy 结合使用 [英] Using Pygame with PyPy

查看:99
本文介绍了将 Pygame 与 PyPy 结合使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对 python 很陌生,但我想通过制作游戏来学习它,而 pygame 似乎是最好的选择.由于 PyPy 是 Python 最快的实现(我认为),因此我决定使用它.但我不知道如何让这两者一起工作.

I'm very new to python but I'd like to learn it by making games and pygame seems to be the best option. Since PyPy is the fastest implementation of python (I think) I decided to use that one. But I have no idea how to get those two working together.

我在窗户上.

如果有人能这么好心地告诉我我需要做什么,我将不胜感激.

If anyone would be so kind to give me a step by step on what I need to do I'd be really grateful.

到目前为止,我已经安装(解压到文件夹)PyPy,将 pypy.exe 设置为打开 .py 文件的默认值,安装 Pygame 并尝试运行示例 .py 文件之一.我在文件中的第一个导入行中收到找不到模块 pygame"错误.

So far, I've installed (extracted to a folder) PyPy, set the pypy.exe as the default for opening .py files, installed Pygame and tried running one of the example .py files. I get the "module pygame not found" error with the first import line in the file.

推荐答案

pygame 不是 与 pypy 兼容,因此要使用它,您必须坚持使用 cPython.

pygame isn't compatible with pypy, so to use it you'll have to stick with cPython.

更新(2018 年 4 月):

正如这个答案中所指出的,PyPy v6.0 版本现在适用于 pygame - 尽管目前还没有稳定版(pygame 1.9.3) 发布,但使用当前的开发分支 (1.9.4.dev0).

As pointed out by in this answer the PyPy v6.0 release now works with pygame - although not yet with the current stable (pygame 1.9.3) release, but with the current developement branch (1.9.4.dev0).

在 ubuntu 17.10 上测试:

tested on ubuntu 17.10 by:

  • 下载并提取最新的 linux 预编译版本
  • 为 pygame 安装构建依赖项:sudo apt build-dep python-pygame
  • 安装pip:./bin/pypy3 -m ensurepip
  • 安装pygame:./bin/pypy3 -m pip install 'Pygame>=1.9.4.dev0'
  • 运行演示:./bin/pypy3 -m pygame.examples.aliens
  • downloading and extracting the latest precompiled version for linux
  • installing the build dependencies for pygame: sudo apt build-dep python-pygame
  • installing pip: ./bin/pypy3 -m ensurepip
  • installing pygame: ./bin/pypy3 -m pip install 'Pygame>=1.9.4.dev0'
  • running the demo: ./bin/pypy3 -m pygame.examples.aliens

适用于 pypy3 和 pypy2 版本.

Works for both the pypy3 and pypy2 versions.

这篇关于将 Pygame 与 PyPy 结合使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆