简体   繁体   English

VPython没有输出

[英]VPython no output

I just managed to install the vpython libraries on Python 3.7, now when i run a code like this: 我刚设法在Python 3.7上安装vpython库,现在当我运行如下代码时:

from visual import *
redbox=box(pos=vector(4,2,3),size=(8,4,6),color=color.red)
ball=sphere(pos=vector(4,7,3),radius=2,color=color.green)

I get this: 我得到这个:

Traceback (most recent call last):
File "C:/Users/Deku/AppData/Local/Programs/Python/Python37/draft.py", line 1, in <module>
from visual import *
ModuleNotFoundError: No module named 'visual'

Now, when i try this: 现在,当我尝试这个:

from vpython import visual

I get this: 我得到这个:

Traceback (most recent call last):
File "<pyshell#6>", line 1, in <module>
from vpython import visual
ImportError: cannot import name 'visual' from 'vpython' (C:\Users\Deku\AppData\Local\Programs\Python\Python37\lib\site-packages\vpython\__init__.py)

How do i get this thing to run properly and do what its supposed to? 我如何使这件事正常运行并执行应做的事情? The documentation on the VPython page doesn't help that much, since the examples it gives even start as "from visual import *" which doesn't seem to work. VPython页面上的文档没有太大帮助,因为它给出的示例甚至以“ from visual import *”开头,这似乎不起作用。

Note: On top of that, i tried the first piece of code, but replaced "visual" with "vpython" and when the code run, it opened a page on my main browser. 注意:最重要的是,我尝试了第一段代码,但是将“ visual”替换为“ vpython”,并且在代码运行时,它在主浏览器上打开了一个页面。 The link address on top reads: " http://localhost:52397/ " but nothing shows or happens. 最上面的链接地址显示为:“ http:// localhost:52397 / ”,但什么也没有显示或没有发生。

Just try using vpython. 只需尝试使用vpython。

from vpython import *

in the latest version of vpython they changed the import module. 在最新版本的vpython中,他们更改了导入模块。

If this also doesn't work it might be related to your IDE. 如果这仍然不起作用,则可能与您的IDE有关。 For example, new version of vpython still doesn't work in Jupyter Lab. 例如,新版本的vpython在Jupyter Lab中仍然不起作用。

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

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