Can't install a working version of vpython 7

164 views
Skip to first unread message

Ted Hoffman

unread,
May 13, 2022, 1:17:28 PM5/13/22
to VPython-users
Hello,

I would like to be able to make use of vpython 7 in Spyder.

I am on a Windows 11 machine and I use Conda to create my python environments.

To install my environment I ran the following from a Anaconda Powershell prompt :
 conda create -n spyder-vpython spyder numpy scipy pandas matplotlib sympy cython vpython -c conda-forge

The results from the creation of the environment are shown in Figure1.png.

From the same Anaconda Powershell prompt I then ran:
conda activate spyder-vpython
spyder

In spyder I ran:
import txaio
import vpython as vp
txaio.use_twisted()
vp.box()

This code failed and I have attached the spyder console output (see attached ipython.html)

I am not sure what I might have done wrong with my installation. I would have preferred to use Visual Studio Code in place of Spyder, but I read in other correspondence that Visual Studio Code is not supported by vpython.

Thanks

ipython.html
Figure1.png

John

unread,
May 13, 2022, 1:55:59 PM5/13/22
to VPython-users
Here is a video tutorial on how to install and run vpython in Visual Studio Code.


There is currently an issue of installing and running vpython in no_notebook mode with an IDE like spyder or Visual Studio Code. After installing vpython you will need to uninstall the packages autobahn and txaio . Then install autobahn version 21.11.1

    pip install autobahn==21.11.1

and this will install txaio version 22.2.1

You can try installing this version of autobahn to see if it will fix your issue with spyder.

John

Ted Hoffman

unread,
May 13, 2022, 4:48:56 PM5/13/22
to vpytho...@googlegroups.com
Hi John,

Thank you for your advice. I did what you said and it worked perfectly. vpython is now working inside of Visual Studio Code.

I knew about the WcWhorter video, but I was shying away from his approach because he was using a pip install of everything and I was trying to stay under the Anaconda umbrella. 

What I did was :

Installed a new python from python.org (version 3.10.4)

Opened a Windows command prompt window and started up Visual Studio Code

In Visual Studio Code:
Created a new directory to hold my vpython code
Selected the python interpreter (version 3.10.4)
ran:
image.png
After the installation I created a python file with the following code:
import vpython
ball = vpython.sphere()
while True:
    pass

When this file is run a new tab in Microsoft Edge (my default browser) opens and a sphere appears.
Without the "while True: pass" errors are generated. 

Thanks
Ted



--
You received this message because you are subscribed to a topic in the Google Groups "VPython-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/vpython-users/97KVwVpkrqE/unsubscribe.
To unsubscribe from this group and all its topics, send an email to vpython-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/vpython-users/f28acf5e-7199-4b5b-833e-c51aa46c229bn%40googlegroups.com.

Kevin Karplus

unread,
May 13, 2022, 9:12:50 PM5/13/22
to vpytho...@googlegroups.com
Shouldn't the "while True" loop have a "rate(10)" statement, rather than a "pass", to keep the Python interpreter from busy-waiting?

Professor Emeritus, UC, Santa Cruz (on 10% recall for 2021–22)
Affiliations for identification only.




You received this message because you are subscribed to the Google Groups "VPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vpython-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/vpython-users/CAG23ivM7MR6NrkEt%3D%3Dtsd%3DKpU9JAfOu4bbiCsOmD%3DRoiZghZ6Q%40mail.gmail.com.

Bruce Sherwood

unread,
May 14, 2022, 1:55:07 PM5/14/22
to VPython-users
Yes, Kevin, you are right. However, somewhat to my surprise, there is one environment where an infinite loop on "pass" doesn't hang the browser, namely with installed Python and no-notebook. The reason for this is that the no-notebook environment uses threads.

Bruce
Reply all
Reply to author
Forward
0 new messages