Error ⚠️ creating a sphere using vpython

Hello! there :wave:

I’m trying to create a sphere, so write this code in the terminal:

pip3 install vpython
from vpython import * 
ball=sphere(radius=2,color=color.red)

I unfortunately got this error message:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/teenoid/.local/lib/python3.9/site-packages/vpython/vpython.py", line 1172, in __init__
    super(sphere, self).setup(args)
  File "/home/teenoid/.local/lib/python3.9/site-packages/vpython/vpython.py", line 599, in setup
    super(standardAttributes, self).__init__()
  File "/home/teenoid/.local/lib/python3.9/site-packages/vpython/vpython.py", line 259, in __init__
    from .no_notebook import _
  File "/home/teenoid/.local/lib/python3.9/site-packages/vpython/no_notebook.py", line 12, in <module>
    from autobahn.asyncio.websocket import WebSocketServerProtocol, WebSocketServerFactory
  File "/home/teenoid/.local/lib/python3.9/site-packages/autobahn/asyncio/__init__.py", line 32, in <module>
    from autobahn.asyncio.websocket import \
  File "/home/teenoid/.local/lib/python3.9/site-packages/autobahn/asyncio/websocket.py", line 36, in <module>
    from autobahn.util import public, hltype
  File "/home/teenoid/.local/lib/python3.9/site-packages/autobahn/util.py", line 49, in <module>
    from OpenSSL import SSL
  File "/usr/lib/python3/dist-packages/OpenSSL/__init__.py", line 8, in <module>
    from OpenSSL import crypto, SSL
  File "/usr/lib/python3/dist-packages/OpenSSL/crypto.py", line 1556, in <module>
    class X509StoreFlags(object):
  File "/usr/lib/python3/dist-packages/OpenSSL/crypto.py", line 1577, in X509StoreFlags
    CB_ISSUER_CHECK = _lib.X509_V_FLAG_CB_ISSUER_CHECK
AttributeError: module 'lib' has no attribute 'X509_V_FLAG_CB_ISSUER_CHECK'
>>> python3
Exception ignored in: <function standardAttributes.__del__ at 0xb61644f0>
Traceback (most recent call last):
  File "/home/teenoid/.local/lib/python3.9/site-packages/vpython/vpython.py", line 1159, in __del__
    super(standardAttributes, self).__del__()
  File "/home/teenoid/.local/lib/python3.9/site-packages/vpython/vpython.py", line 340, in __del__
    cmd = {"cmd": "delete", "idx": self.idx}
AttributeError: 'sphere' object has no attribute 'idx'
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
NameError: name 'python3' is not defined
>>> 
exit
Error in atexit._run_exitfuncs:
Traceback (most recent call last):
  File "/home/teenoid/.local/lib/python3.9/site-packages/vpython/vpython.py", line 22, in Exit
    a = 1.0/zero
ZeroDivisionError: float division by zero
teenoid@raspberrypi:~/Exercises $ python3
Python 3.9.2 (default, Mar 12 2021, 04:06:34) 
[GCC 10.2.1 20210110] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import vpython
im>>> import numpy
>>> from vpython import *
>>> ball=sphere(radius=2,color=color.red)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/teenoid/.local/lib/python3.9/site-packages/vpython/vpython.py", line 1172, in __init__
    super(sphere, self).setup(args)
  File "/home/teenoid/.local/lib/python3.9/site-packages/vpython/vpython.py", line 599, in setup
    super(standardAttributes, self).__init__()
  File "/home/teenoid/.local/lib/python3.9/site-packages/vpython/vpython.py", line 259, in __init__
    from .no_notebook import _
  File "/home/teenoid/.local/lib/python3.9/site-packages/vpython/no_notebook.py", line 12, in <module>
    from autobahn.asyncio.websocket import WebSocketServerProtocol, WebSocketServerFactory
  File "/home/teenoid/.local/lib/python3.9/site-packages/autobahn/asyncio/__init__.py", line 32, in <module>
    from autobahn.asyncio.websocket import \
  File "/home/teenoid/.local/lib/python3.9/site-packages/autobahn/asyncio/websocket.py", line 36, in <module>
    from autobahn.util import public, hltype
  File "/home/teenoid/.local/lib/python3.9/site-packages/autobahn/util.py", line 49, in <module>
    from OpenSSL import SSL
  File "/usr/lib/python3/dist-packages/OpenSSL/__init__.py", line 8, in <module>
    from OpenSSL import crypto, SSL
  File "/usr/lib/python3/dist-packages/OpenSSL/crypto.py", line 1556, in <module>
    class X509StoreFlags(object):
  File "/usr/lib/python3/dist-packages/OpenSSL/crypto.py", line 1577, in X509StoreFlags
    CB_ISSUER_CHECK = _lib.X509_V_FLAG_CB_ISSUER_CHECK
AttributeError: module 'lib' has no attribute 'X509_V_FLAG_CB_ISSUER_CHECK'
>>> 
exit
Error in atexit._run_exitfuncs:
Traceback (most recent call last):
  File "/home/teenoid/.local/lib/python3.9/site-packages/vpython/vpython.py", line 22, in Exit
    a = 1.0/zero
ZeroDivisionError: float division by zero
Exception ignored in: <function standardAttributes.__del__ at 0xb618d4f0>
Traceback (most recent call last):
  File "/home/teenoid/.local/lib/python3.9/site-packages/vpython/vpython.py", line 1159, in __del__
    super(standardAttributes, self).__del__()
  File "/home/teenoid/.local/lib/python3.9/site-packages/vpython/vpython.py", line 340, in __del__
    cmd = {"cmd": "delete", "idx": self.idx}
AttributeError: 'sphere' object has no attribute 'idx'




So I took the following steps to try fix this error:

  1. Head to Stackoverflow & followed the instructions here python - AttributeError: module 'lib' has no attribute 'X509_V_FLAG_CB_ISSUER_CHECK' - Stack Overflow
  2. Typed in the below commands (that I found in the Stackoverflow post above) in my terminal:
pip install pip --upgrade
pip install pyopenssl --upgrade
sudo apt-get --reinstall install python-apt
sudo apt-get --reinstall install apt-transport-https
sudo apt-get install build-essential libssl-dev libffi-dev python-dev

Note: As a newbie, have no idea what these commands mean, I just wanted to try and see if they worked.

  1. I then typed this into my terminal again to see if the Stackoverflow instructions worked:
from vpython import * 
ball=sphere(radius=2,color=color.red)
  1. I get the same error message I received the first time (the one I pasted at the top of this post)




Why am I receiving this error message? And is there a way to get my red sphere to appear with my Pi?

Thanks!

2 Likes

Initially got the same error, eventually got it to work after reading a few forum posts.
(forums sometimes have information that does not help, or related to different problem)

Pi 4B
Opened Terminal window
pip3 install vpython
Many downloads

Opened Thonny

import vpython import *
sphere(radius=2,color=color.red)

Same error

In Terminal window
sudo pip install pyOpenSSL --upgrade
A few downloads

In Thonny
sphere(radius=2,color=color.red)
Web page opened localhost:53865 with red sphere displayed.

So its just pyOpenSSL that is needs to be installed, give that a go, may work.
Cheers
Jim

2 Likes