Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Anaconda / Spyder / VPython
#1
Hi,

Has anyone had experience installing the VPython module in Anaconda and running it within Spyder?

My company laptop has Anaconda and Spyder pre-italled and so it would be great to get VPython working with it. Main reason is, I cannot freely download VPython myself without jumping hoops with my IT department.

After downloading VPython in Anaconda I ran a basic script (for testing purposes) to display a sphere or a box...

from vpython import *
box()
I got the following output in the console...

runfile('C:/Users/WATS6441/.spyder-py3/sphere.py', wdir='C:/Users/WATS6441/.spyder-py3')
And no window appears showing the box / sphere.


I'd like to steer clear of downloading python then vpython and all the additional modules required as they all require admin IT input, but Anaconda lets me do it all through the navigator. Spyder doesn't kick up a fuss about Vpython not being found so I assume that is not the problem, but instead an issue with the rendering window.

Has anyone has similar experience or recommend another module I can use that can model simple 3D projectiles like Vpython.


Thanks for reading.

Kind Regards,

Martin
Reply
#2
Have you tried conda to install?
Example:
G:\Anaconda3\Scripts
λ conda install -c vpython vpython
Solving environment: done

## Package Plan ##

  environment location: G:\Anaconda3

  added / updated specs:
    - vpython


The following packages will be downloaded:

    package                    |            build
    ---------------------------|-----------------
    certifi-2018.4.16          |           py36_0         143 KB
    vpnotebook-0.1.3           |           py36_1          10 KB  vpython
    autobahn-18.3.1            |             py_0         161 KB  vpython
    vpython-7.4.4              |           py36_0         3.8 MB  vpython
    conda-4.5.4                |           py36_0         1.0 MB
    txaio-2.9.0                |             py_0          19 KB  vpython
    ujson-1.35                 |           py36_0          23 KB
    ------------------------------------------------------------
                                           Total:         5.1 MB

The following NEW packages will be INSTALLED:

    autobahn:   18.3.1-py_0      vpython
    txaio:      2.9.0-py_0       vpython
    ujson:      1.35-py36_0
    vpnotebook: 0.1.3-py36_1     vpython
    vpython:    7.4.4-py36_0     vpython

The following packages will be UPDATED:

    certifi:    2018.1.18-py36_0         --> 2018.4.16-py36_0
    conda:      4.5.0-py36_0             --> 4.5.4-py36_0

Proceed ([y]/n)? y


Downloading and Extracting Packages
certifi 2018.4.16: ################################################################################### | 100%
vpnotebook 0.1.3: #################################################################################### | 100%
autobahn 18.3.1: ##################################################################################### | 100%
vpython 7.4.4: ####################################################################################### | 100%
conda 4.5.4: ######################################################################################### | 100%
txaio 2.9.0: ######################################################################################### | 100%
ujson 1.35: ########################################################################################## | 100%
Preparing transaction: done
Verifying transaction: done
Executing transaction: done
Test:
G:\Anaconda3
λ python -m ptpython
>>> from vpython import *

>>> box(color=color.orange,material=color.white)
<vpython.vpython.box object at 0x000001D33F4CF3C8>
Look at my Anaconda tutorial.
If admin also stop conda and pip,i would build it at home with Miniconda - vpython,and used it from usb stick.
Reply
#3
This is fantastic help! Thank you very much.

With the amount of lunix distros I have on bootable USB devices I don't know why I didnt think about this approach. I will have a look over the next few days and let you know how I get on!

UPDATE:

When I type in the following into the python shell

>>> from vpython import *
>>> box(color=color.orange,material=color.white)
I get

<vpython.vpython.box object at 0x000001D33F4CF3C8> 
And a new iexplorer tab opens up, URL is 'http://localhost:65251/' with a black box in the tab, with no model of a box. I also tried sphere to be sure and same thing.... just a black box.

Reverting back to Spyder and tring the same input as above the output is...

runfile('C:/Users/WATS6441/.spyder-py3/sphere.py', wdir='C:/Users/WATS6441/.spyder-py3')
<IPython.core.display.Javascript object>
<IPython.core.display.Javascript object>
<IPython.core.display.Javascript object>
<IPython.core.display.Javascript object>
<IPython.core.display.Javascript object>
<IPython.core.display.Javascript object>
<IPython.core.display.HTML object>
<IPython.core.display.Javascript object>
But this time no iexplorer tab opens up...

Any ideas?
Reply
#4
How it work for me.
As a scripts:
# vs.py
from vpython import *

ball = sphere(pos=vector(0,10,0), radius=1, color=color.red)
G:\Anaconda3
λ python vs.py
It's open a tab in default browser(for me Chrome) at localhost:35438 and show a red ball.

Inter active shell,i use ptpython.
It open browser loacahost tab on import,then the same show the red ball on enter next line.
G:\Anaconda3
λ python -m ptpython
>>> from vpython import *

>>> ball = sphere(pos=vector(0,10,0), radius=1, color=color.red)
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  I try to import Vpython and I get a "ZeroDivisionError" Jon2222 16 2,470 Jul-26-2023, 07:37 AM
Last Post: Jon2222
  Use different Anaconda environments on Linux Mint and Spyder StaLLoNe_CoBRa 0 1,841 Jan-20-2021, 03:12 AM
Last Post: StaLLoNe_CoBRa
  Anaconda Spyder erratically reset by distutils C extension OTAGOHARBOUR 4 2,358 Nov-27-2019, 01:51 PM
Last Post: ThomasL
  Vpython Delay in plotting points SohaibAJ 0 2,036 Jul-30-2018, 08:44 PM
Last Post: SohaibAJ
  VPython - Trying to make orbit simulation totalnoob 2 5,559 Sep-13-2017, 03:59 PM
Last Post: micseydel

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020