Aug-25-2019, 05:20 PM
Does anyone know how to deal with not being able to call VPython objects from the module?
I am trying to learn how to use VPython to produce 3D grpahics and animations for my upcoming senior physics research and am running into issues with even being able to utilize the module. I have tried a few things such as copying the module into the same folder as the folder where my python code is at, adding paths on the PYTHONPATH manager, and reinstalling VPython using conda install but none of that has worked.
My code is as follows:
and I got the exact same messages as before.
In case it is relevant I am running python 3.7.4, spyder 3.3.6, Anaconda 2019.07 on Windows 10
So I am kind of at a loss right now. Also it might be worth noting that if I were to try to use another object like box or cone I get the EXACT same import error telling me that it cannot import name 'sphere' from vpython instead of box or cone or whatever else.
I am trying to learn how to use VPython to produce 3D grpahics and animations for my upcoming senior physics research and am running into issues with even being able to utilize the module. I have tried a few things such as copying the module into the same folder as the folder where my python code is at, adding paths on the PYTHONPATH manager, and reinstalling VPython using conda install but none of that has worked.
My code is as follows:
from vpython import sphere,rate from math import cos,sin,pi from numpy import arange s = sphere(pos=[1,0,0],radius=0.1) for theta in arange(0,10*pi,0.1): rate(30) x = cos(theta) y = sin(theta) s.pos = [x,y,0]I get the following in the console
Error: runfile('C:/Users/antho/OneDrive/Desktop/New folder/untitled0.py', wdir='C:/Users/antho/OneDrive/Desktop/New folder')
Traceback (most recent call last):
File "<ipython-input-13-02201f1d4932>", line 1, in <module>
runfile('C:/Users/antho/OneDrive/Desktop/New folder/untitled0.py', wdir='C:/Users/antho/OneDrive/Desktop/New folder')
File "C:\Users\antho\Anaconda3\lib\site-packages\spyder_kernels\customize\spydercustomize.py", line 827, in runfile
execfile(filename, namespace)
File "C:\Users\antho\Anaconda3\lib\site-packages\spyder_kernels\customize\spydercustomize.py", line 110, in execfile
exec(compile(f.read(), filename, 'exec'), namespace)
File "C:/Users/antho/OneDrive/Desktop/New folder/untitled0.py", line 1, in <module>
from vpython import box
File "C:\Users\antho\vpython.py", line 1, in <module>
from vpython import sphere
ImportError: cannot import name 'sphere' from 'vpython' (C:\Users\antho\vpython.py)
So I tried to just simply display a sphere without animations or special condition from vpython import sphere sphere()
and I got the exact same messages as before.
In case it is relevant I am running python 3.7.4, spyder 3.3.6, Anaconda 2019.07 on Windows 10
So I am kind of at a loss right now. Also it might be worth noting that if I were to try to use another object like box or cone I get the EXACT same import error telling me that it cannot import name 'sphere' from vpython instead of box or cone or whatever else.