我们如何在Google Colab上使用pygame? [英] How can we use pygame on Google Colab?

查看:129
本文介绍了我们如何在Google Colab上使用pygame?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用q learning来使我的游戏自动化,并且正在考虑使用colab来获得其他一些GPU支持.安装需求并运行代码后,colab会发出此错误:

I am trying to use q learning to automate my game and was thinking of using colab for some additional GPU support. After installing the requirements and running the code, colab gives out this error:

> error:
> Traceback (most recent call last)
<ipython-input-16-28b090095233> in <module>()
      5 
      6 pygame.font.init()
----> 7 pygame.display.list_modes()
      8 pygame.init()
      9 

>error: video system not initialized 

如果有人可以解决此错误或告诉我如何使用VNC解决此问题.

If someone can solve this error or tell me how to use VNC to solve this problem.

我尝试了 pygame .init()以及 pygame.display.list_modes()

推荐答案

PyGame 只能使用本地视频卡和本地监视器.

PyGame can use only local video card and local monitor.

当您在服务器上运行代码时,它会尝试使用服务器中安装的视频卡并监视连接到该服务器的监视器(您看不到).

When you run code on server then it try to use video card installed in server and monitor connected to this server which you can't see.

但是您甚至无法运行它,因为通常服务器没有视频卡和监视器,因为没有人可以看到此监视器(服务器的管理员除外).

But you can't even run it because usually servers don't have video card and monitor because nobody could see this monitor (except server's admin).

编辑:如果服务器具有视频卡,则必须在 list_modes() pygame.display.init()>

if server has video card then you have to run pygame.display.init() before list_modes()

 pygame.display.init()
 print( pygame.display.list_modes() )

pygame.init(),它们应运行 pygame.display.init()(以及其他 init())

or pygame.init() which should run pygame.display.init() (and other init())

 pygame.init()
 print( pygame.display.list_modes() )

这篇关于我们如何在Google Colab上使用pygame?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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