简体   繁体   English

与 python 安装一起使用时,VPython 的行为很奇怪,并且不会很好地关闭

[英]VPython acts weird when used with python installation and won't shut down nicely

I want to build physics simulations using VPython.我想使用 VPython 构建物理模拟。 Although, VPython works great on websites like trinket.io, I'd like to use a nicer IDE than the web one, and I'd like to use real python modules as well as external libraries like numpy.尽管 VPython 在像 trinket.io 这样的网站上运行良好,但我想使用比 Web 更好的 IDE,并且我想使用真正的 Python 模块以及像 numpy 这样的外部库。

I followed the instructions at https://vpython.org/presentation2018/install.html to install VPython locally.我按照https://vpython.org/presentation2018/install.html上的说明在本地安装 VPython。 I used the command pip install vpython (not really a fan of conda ) and wrote this simple demo program:我用命令pip install vpython (不是真正的粉丝conda ),并写了这个简单的演示程序:

from vpython import sphere

sphere()

When I ran this from the command line, the program indeed worked: a browser window opened displaying the sphere.当我从命令行运行此程序时,该程序确实有效:打开了一个显示球体的浏览器窗口。 However, there are several issues with this setup:但是,这种设置有几个问题:

  • When looking at the console, it keeps throwing a weird error RuntimeError: can't register atexit after shutdown .查看控制台时,它不断抛出一个奇怪的错误RuntimeError: can't register atexit after shutdown However, it still seems to run fine.但是,它似乎仍然运行良好。
  • I couldn't find a way to nicely stop the simulation.我找不到很好地停止模拟的方法。 Closing the browser tab doesn't exit the program.关闭浏览器选项卡不会退出程序。 Pressing Ctrl+C also doesn't do anything useful.Ctrl+C也没有任何用处。 The only way to stop it is to use Ctrl+Break , which is a really dirty way, in my opinion.阻止它的唯一方法是使用Ctrl+Break ,在我看来,这是一种非常肮脏的方式。 I tried to use stop_server as documented in that link, but no result.我尝试使用该链接中记录的stop_server ,但没有结果。

Is there a way to fix these issues or maybe a different environment that will answer my needs?有没有办法解决这些问题,或者可能有一个不同的环境来满足我的需求? I really want to be able to use built-in python modules and external libraries like numpy but it seems impossible at the moment.我真的很想能够使用内置的 python 模块和像 numpy 这样的外部库,但目前似乎不可能。

根据此讨论是 Python 版本的问题

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM