Problem with visual.graph

511 views
Skip to first unread message

mateusz...@gmail.com

unread,
Nov 4, 2013, 7:22:16 AM11/4/13
to vpytho...@googlegroups.com
Hello,
I have some problem with programs where I import * from visual.graph. When I want to start him there shows some window with message dialog that program.exe stopped working. When I import * from visual everything is ok. How can I resolve that problem ??

Bruce Sherwood

unread,
Nov 4, 2013, 11:24:35 AM11/4/13
to vpytho...@googlegroups.com
Not sure this is the problem, but note that if you're using VPython 6.x the following sentence from the first page of the VPython 6.x documentation may be the issue:

"You must import visual or vis before importing graph or controls or filedialog, which most users have always done anyway."

So to use a graph with VPython 6.x you need to do something like this:

from visual import *
from visual.graph import *

If this doesn't solve your problem, please provide a short test routine that fails for you. Thanks.

mateusz...@gmail.com

unread,
Nov 4, 2013, 12:17:35 PM11/4/13
to vpytho...@googlegroups.com
from visual import *
from visual.graph import *

l=5
k=89
k=k*pi/180
g=9.81
dt=0.01
vk=0

w=500
display(title='pendulum', x=0, y=0, width=w, height=w)
kulx=l*sin(k)
kuly=l*cos(k)
suf=box(pos=vector(0, 0.5/2, 0), size=(1, 0.5, 1), color=color.red)
sznur=cylinder(pos=(0,0,0), axis=(kulx, -kuly,0), radius=0.02)
kula=sphere(pos=(kulx,-kuly,0), axis=(0,0,1), radius=0.15, color=color.green)

h=w/2
gdisplay(title='chart', x=w+1, y=0, width=w, height=h)
st=gcurve(color=color.blue)
wt=gcurve(color=color.yellow)

t=0
while True:
    rate(100)

    vk=vk-dt*g/l*sin(k)
    k=k+vk

    kulx=l*sin(k)
    kuly=l*cos(k)
    kula.pos=vector(kulx,-kuly,0)
    sznur.axis=vector(kulx, -kuly,0)
    s=l*k
    t +=dt

st.plot(pos=(t,s))
wt.plot(pos=(t,vk))

Bruce Sherwood

unread,
Nov 4, 2013, 5:00:41 PM11/4/13
to vpytho...@googlegroups.com
Your program runs fine on my Windows 7 machine using Python 2.7 (from python.org) and VPython 6.05. In the program you posted, the graph plotting statements at the end were unindented, so no graph was produced. When I indent those two statements, not only does the pendulum move but the graph is also produced.

What platform are you using? What versions of Python and VPython? What exactly is the error message you get? You said something about not getting an error message if you just imported visual: do you mean that if you remove all the graphing statements (including the import statement) the pendulum oscillates?

Minor points: The statement k = k+vk should be k = k+vk*dt. It's quite interesting to start with k = 179 degrees; you get an unusual graph.

MK

unread,
Nov 5, 2013, 10:27:50 AM11/5/13
to vpytho...@googlegroups.com
thanks, I forgot about that dt :).
Python 2.7, VPython 6.05

When I run the program, window with chart is empty

http://speedy.sh/RrdMU/pend.jpg

Pendulum is working ok, but if I want to plot charts there is a problem

Bruce Sherwood

unread,
Nov 5, 2013, 11:18:30 AM11/5/13
to vpytho...@googlegroups.com
I say again that in the program you posted, the graph plotting statements at the end were unindented, so no graph was produced. When I indent those two statements, not only does the pendulum move but the graph is also produced.

The window with chart is empty because in your loop you don't execute any statements for plotting a graph.

MK

unread,
Nov 6, 2013, 4:20:16 AM11/6/13
to vpytho...@googlegroups.com
Sorry, my mistake
I indent them and there is a main problem.  Now when I start the program,  there appears a window that "program pythonw.exe has stopped working"

What should I do ??

I want to highlight that everything is ok with other programs where I don't have to plot or use that virtual.graph

Bruce Sherwood

unread,
Nov 6, 2013, 11:03:37 AM11/6/13
to vpytho...@googlegroups.com
That's quite unusual. I can think of only two possibilities:

1) The graphing module is corrupted. You might try uninstalling and reinstalling.

2) The graphics driver needs to be updated.

There are two programs in the set of VPython examples that make graphs, gas.py and graphtest.py. Do those programs work properly?

MK

unread,
Nov 7, 2013, 3:44:18 AM11/7/13
to vpytho...@googlegroups.com
1) I tried 3 times. It doesn't help
2) How can I update that driver ??

these two programs don't work too.

Bruce Sherwood

unread,
Nov 7, 2013, 11:34:16 AM11/7/13
to vpytho...@googlegroups.com
Since uninstalling and reinstalling didn't help, but you can run programs that don't make graphs, it is nearly certain that you need to update the graphics driver, the software used by the graphics card to make displays, using the OpenGL 3D graphics library that is part of all operating systems.

Since you're on Windows, here is what you need to do:

In the Windows Control Panel, type "system" and then choose "View advanced system settings".

Click the "Hardware" tab, then click "Device Manager", then click the little triangle to the left of "Display adapters".

You should now see the manufacturer and model number of your graphics card. For example, I see "NVIDIA GeForce GTX 680". Double-click this listing, then click the "Driver" tab, and you will probably see details of the driver version and an option "Update Driver". If not, there are two possible sources of an updated graphics driver: the manufacturer of your computer, or the manufacturer of your graphics card. In one of these two places you should be able to find download and installation instructions.

You may wish to share with us the system information you find about your graphics card.

MK

unread,
Nov 8, 2013, 12:11:13 PM11/8/13
to vpytho...@googlegroups.com
ATI Mobility Radeon HD 4500 series

Update Driver wizard said that "driver software for your device is up to date"

OK, I suppose that I need to invest for a new graphic driver. If am I right what do I have to look for when I will want to buy ??

Bruce Sherwood

unread,
Nov 8, 2013, 1:56:27 PM11/8/13
to vpytho...@googlegroups.com
The 4500 is a decent graphics card, first released in 2009, it ought to be able to handle VPython graphics, and you found that the driver software is up to date. So my guess that you need to update the graphics driver seems to be wrong. There isn't some new graphics driver to buy; you already have the most up-to-date version. I suppose you could reinstall the graphics driver by getting it from the Radeon site, on the chance that something has gone wrong with that software.

The only other thing I can think of is that there is some Windows file that is broken. It occurs to me that you may find that the VPython example program labels.py also gives the error; what's special about graphing is that it uses label objects to display 2D text in the scene. If labels.py gives an error, that would seem to imply that there is some Windows library that is broken on your computer.


Reply all
Reply to author
Forward
0 new messages