问题
NameError: name 'gsprint' is not defined
I repeatedly get this error message when trying to run this:
from vpython import *
box()
I am using Python 3.7.3 and Spyder 3.3.4, and cannot find any help in documentation. Vpython website says I should be able to run it:
https://vpython.org/presentation2018/install.html
回答1:
I had the same issue: I kept getting these "NameError: name 'gsprint' is not defined" error
messages when running codes with the from vpython import *
line. Strangely, the same codes on Anaconda/Spyder in another computer were working fine.
I ended up in this page while looking for a solution. I tried the simple vpython code above and got the same error message running from spyder while it worked fine running directly in the Anaconda prompt. I checked that the vpython version in the environment is 7.5.0
.
My solution: an overall update on Anaconda
conda update --all
I'm now running with Spyder 3.3.6
and Python 3.7.3
and the code is working fine.
来源:https://stackoverflow.com/questions/56145089/error-running-vpython-in-spyder-nameerror-name-gsprint-is-not-defined