-1

I am trying to use DialogFlow to make a small talk chatbot on Raspberry Pi 4, and I am getting this error:

ImportError: /usr/local/lib/python3.7/dist-packages/grpc/_cython/cygrpc.cpython-37m-arm-linux-gnueabihf.so: undefined symbol: aes_hw_encrypt

My code is as follows:

"""
Libraries used:

dialogflow        1.1.0 - I did pip3 install dialogflow -U and it upgraded to this
google-api-core   1.29.0
os   Latest version - not sure 

"""

import os
import dialogflow
from google.api_core.exceptions import InvalidArgument

os.environ["GOOGLE_APPLICATION_CREDENTIALS"] = 'secrets.json'

DIALOGFLOW_PROJECT_ID = '[test_id]'
DIALOGFLOW_LANGUAGE_CODE= '[en]'
SESSION_ID = 'me'

text_to_be_analyzed = "Howdy"

session_client = dialogflow.SessionsClient()
session = session_client.session_path(DIALOGFLOW_PROJECT_ID, SESSION_ID)
text_input = dialogflow.types.TextInput(text=text_to_be_analyzed, language_code=DIALOGFLOW_LANGUAGE_CODE)
query_input = dialogflow.types.QueryInput(text=text_input)
try:
    response = session_client.detect_intent(session=session, query_input=query_input)
except InvalidArgument:
    raise

print("Query text:", response.query_result.query_text)
print("Detected intent:", response.query_result.intent.display_name)
print("Detected intent confidence:", response.query_result.intent_detection_confidence)
print("Fulfillment text:", response.query_result.fulfillment_text)

pip3 list gives me:

-------------------------------- ---------------
Adafruit-BBIO                    1.2.0          
Adafruit-Blinka                  6.10.0         
Adafruit-CharLCD                 1.1.1          
adafruit-circuitpython-busdevice 5.0.6          
adafruit-circuitpython-framebuf  1.4.7          
adafruit-circuitpython-ssd1306   2.11.4         
Adafruit-GPIO                    1.0.3          
Adafruit-ILI9341                 1.5.1          
Adafruit-PlatformDetect          3.13.3         
Adafruit-PureIO                  1.1.8          
Adafruit-SSD1306                 1.6.2          
appdirs                          1.4.3          
asn1crypto                       0.24.0         
astroid                          2.1.0          
asttokens                        1.1.13         
attrs                            21.2.0         
automationhat                    0.2.0          
beautifulsoup4                   4.7.1          
blinker                          1.4            
blinkt                           0.1.2          
bs4                              0.0.1          
buttonshim                       0.0.2          
cachetools                       4.2.2          
Cap1xxx                          0.1.3          
certifi                          2018.8.24      
chardet                          3.0.4          
Click                            7.0            
colorama                         0.3.7          
colorzero                        1.1            
cookies                          2.2.1          
cryptography                     2.6.1          
cupshelpers                      1.0            
cycler                           0.10.0         
decorator                        4.4.2          
dialogflow                       1.1.0          
docutils                         0.14           
drumhat                          0.1.0          
entrypoints                      0.3            
envirophat                       1.0.0          
ExplorerHAT                      0.4.2          
flake8                           3.9.2          
Flask                            1.0.2          
fourletterphat                   0.1.0          
fuzzywuzzy                       0.18.0         
google-api-core                  1.29.0         
google-auth                      1.30.1         
googleapis-common-protos         1.53.0         
gpiozero                         1.5.1          
grpcio                           1.38.0         
guizero                          0.6.0          
html5lib                         1.0.1          
idna                             2.6            
imageio                          2.9.0          
importlib-metadata               4.0.1          
iniconfig                        1.1.1          
ipykernel                        4.9.0          
ipython                          5.8.0          
ipython-genutils                 0.2.0          
isort                            4.3.4          
itsdangerous                     0.24           
jaraco.context                   4.0.0          
jedi                             0.13.2         
Jinja2                           2.10           
jupyter-client                   5.2.3          
jupyter-core                     4.4.0          
keyring                          17.1.1         
keyrings.alt                     3.1.1          
kiwisolver                       1.3.1          
lazy-object-proxy                1.3.1          
logilab-common                   1.4.2          
lxml                             4.3.2          
MarkupSafe                       1.1.0          
matplotlib                       3.4.2          
mccabe                           0.6.1          
microdotphat                     0.2.1          
mongo-db                         0.1            
more-itertools                   8.8.0          
mote                             0.0.4          
motephat                         0.0.3          
mypy                             0.670          
mypy-extensions                  0.4.1          
networkx                         2.5.1          
nightly                          0.0.1          
nudatus                          0.0.4          
numpy                            1.20.3         
oauthlib                         2.1.0          
olefile                          0.46           
packaging                        20.9           
pandas                           1.2.4          
pantilthat                       0.0.7          
parso                            0.3.1          
pexpect                          4.6.0          
pgzero                           1.2            
phatbeat                         0.1.1          
pianohat                         0.1.0          
picamera                         1.13           
pickleshare                      0.7.5          
piglow                           1.2.5          
pigpio                           1.78           
Pillow                           8.2.0          
pip                              18.1           
pluggy                           0.13.1         
prompt-toolkit                   3.0.18         
protobuf                         3.17.2         
psutil                           5.5.1          
py                               1.10.0         
pyasn1                           0.4.8          
pyasn1-modules                   0.2.8          
pycairo                          1.16.2         
pycodestyle                      2.7.0          
pycrypto                         2.6.1          
pycups                           1.9.73         
pyflakes                         2.3.1          
pyftdi                           0.53.1         
pygame                           1.9.4.post1    
Pygments                         2.3.1          
PyGObject                        3.30.4         
pyinotify                        0.9.6          
PyJWT                            1.7.0          
pylint                           2.2.2          
pymongo                          3.4.0          
pyOpenSSL                        19.0.0         
pyparsing                        2.4.7          
pyserial                         3.4            
pysmbc                           1.0.15.6       
pytest                           6.2.4          
python-apt                       1.8.4.3        
python-dateutil                  2.8.1          
python-espeak                    0.5            
python-Levenshtein               0.12.2         
pytz                             2021.1         
pyusb                            1.1.1          
PyWavelets                       1.1.1          
pyxdg                            0.25           
PyYAML                           5.4.1          
pyzmq                            17.1.2         
qtconsole                        4.3.1          
rainbowhat                       0.1.0          
reportlab                        3.5.13         
requests                         2.21.0         
requests-oauthlib                1.0.0          
responses                        0.9.0          
roman                            2.0.0          
rpi-ws281x                       4.2.6          
RPi.GPIO                         0.7.0          
rsa                              4.7.2          
RTIMULib                         7.2.1          
scikit-image                     0.18.1         
scipy                            1.6.3          
screen                           1.0.1          
scrollphat                       0.0.7          
scrollphathd                     1.2.1          
SecretStorage                    2.3.1          
semver                           2.0.1          
Send2Trash                       1.5.0          
sense-hat                        2.2.0          
setuptools                       40.8.0         
simplegeneric                    0.8.1          
simplejson                       3.16.0         
six                              1.16.0         
skywriter                        0.0.7          
sn3218                           1.2.7          
soupsieve                        1.8            
sox                              1.4.1          
spidev                           3.4            
ssh-import-id                    5.7            
sysv-ipc                         1.1.0          
thonny                           3.3.6          
tifffile                         2021.4.8       
toml                             0.10.2         
torch                            1.0.0a0+8322165
torchvision                      0.2.0          
tornado                          5.1.1          
touchphat                        0.0.1          
traitlets                        4.3.2          
twython                          3.7.0          
typed-ast                        1.3.1          
typing                           3.7.4.3        
typing-extensions                3.10.0.0       
uflash                           1.2.4          
unicornhathd                     0.0.4          
urllib3                          1.24.1         
wcwidth                          0.2.5          
webencodings                     0.5.1          
Werkzeug                         0.14.1         
wheel                            0.32.3         
wit                              6.0.0          
wolframalpha                     5.0.0          
wrapt                            1.10.11        
xmltodict                        0.12.0         
zipp                             3.4.1   

I might have accidentally installed the libraries some other way when I updated, but I don't think so...

I didn't install anything using apt.

I am using Thonny Python. Thanks!

g3holliday
  • 21
  • 9
  • Do you have all the relevant crypto librarys installed ? – Chris Doyle Jun 07 '21 at 18:01
  • I think.... What ones would I be missing? – g3holliday Jun 07 '21 at 18:03
  • 1
    The libraries that you are using are very old. Update your system. For example, `dialogflow` is now at version `2.4.0`. – John Hanley Jun 07 '21 at 21:51
  • That was a mistake. I am actually using the latest ones. I updated the code to reflect that. Thanks! – g3holliday Jun 07 '21 at 22:08
  • 1
    Just saying you have the "latest" version is pretty empty, since your mistake could be misunderstanding what version is the latest. Tell us the version numbers! It would also help if you clarified if you're still having the same error with the recent libraries, or if you never did have those older versions, and the error was with the recent versions all along. – Blckknght Jun 07 '21 at 22:19
  • Spend the time to create accurate questions with all details. Edit your question and include the output from `pip list`. Also, read this article: https://stackoverflow.com/help/how-to-ask – John Hanley Jun 07 '21 at 22:27
  • I updated the question with the versions. Thanks, guys! – g3holliday Jun 07 '21 at 22:48
  • 2
    Hello, I was unable to replicate the error. I created a virtual env and installed the libraries you mentioned. I am not getting the same ImportError. It would be really useful if you could share either your `pip freeze` or `pip list` to try to troubleshoot it. – Yael Araizaga Jun 07 '21 at 22:48
  • 1
    As a note, I used this command `grep -R aes_hw_encrypt` to find the instances of "aes_hw_encrypt" in my environment. I found it under `test_venv/lib/python3.7/site-packages/grpc/_cython/cygrpc.cpython-37m-x86_64-linux-gnu.so`. Notice how mine is under `site-packages` vs. yours in `dist-packages` from the exception. This means that your grpc was most likely installed via `apt` instead of `pip` which installs in site-packages. It is possible that something from your environment is clashing with the code. I suggest trying it out on a virtual environment. – Yael Araizaga Jun 07 '21 at 22:49
  • I have updated the post to reflect `pip3 freeze` and `pip3 list`. Thanks! – g3holliday Jun 07 '21 at 23:24
  • Also, I'm on a Raspberry Pi 4, but I didn't post this in the RPI community because it isn't a RPI problem, it's a Python problem. – g3holliday Jun 07 '21 at 23:34
  • That detail (RPI) should have been detailed in your question at the top. The platform affects the libraries which does make this a RPI isue. Also, you stated `latest` for `dialogflow`. Again, details matter, you do NOT have the latest versions. – John Hanley Jun 07 '21 at 23:47
  • Sorry :) I meant latest I could get. Also, I forgot to put that in the question. It was in my first draft, but that was deleted by a WiFi crash :| – g3holliday Jun 08 '21 at 00:00
  • 1
    Hey, I tried installing all the same libraries to reproduce, but I can still execute the code correctly. I believe there is too much noise in your environment to effectively troubleshoot the issue. I heavily recommend [creating a virtual environment](https://docs.python.org/3/library/venv.html) and installing only the minimum amount of libraries needed for this code. While I was trying to reproduce there were many library errors, and we would like to ensure those are not causing the issue – Yael Araizaga Jun 08 '21 at 15:23
  • OK, I'll try that, Thanks! – g3holliday Jun 08 '21 at 17:04
  • When I try to install Dialogflow in my venv, I get this: Running setup.py bdist_wheel for grpcio ... error Complete output from command /home/pi/my_venv/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-install-0r15dn1n/grpcio/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" bdist_wheel -d /tmp/pip-wheel-bk8_sonp --python-tag cp37 error: invalid command 'bdist_wheel – g3holliday Jun 10 '21 at 17:44
  • You need to run `pip install wheel` here is a [related thread on that issue](https://stackoverflow.com/questions/34819221/why-is-python-setup-py-saying-invalid-command-bdist-wheel-on-travis-ci) – Yael Araizaga Jun 11 '21 at 20:47
  • That was dumb. Sorry. :) – g3holliday Jun 11 '21 at 20:57
  • Also, same error in the venv..... – g3holliday Jun 12 '21 at 17:09
  • I tried to put the errror in the above question, but it gave me this: Your post cannot be submitted at this time due to the volume of spam and abuse originating from your network. We apologize for any inconvenience. – g3holliday Jun 12 '21 at 17:17
  • new_bot_8_2.py Traceback (most recent call last): File "new_bot_8_2.py", line 2, in import dialogflow File "/home/pi/my_venv/lib/python3.7/site-packages/dialogflow/__init__.py", line 17, in from dialogflow_v2 import AgentsClient File "/home/pi/my_venv/lib/python3.7/site-packages/dialogflow_v2/__init__.py", line 23, in from dialogflow_v2.gapic import agents_client – g3holliday Jun 12 '21 at 17:19
  • File "/home/pi/my_venv/lib/python3.7/site-packages/dialogflow_v2/gapic/agents_client.py", line 25, in import google.api_core.gapic_v1.client_info File "/home/pi/my_venv/lib/python3.7/site-packages/google/api_core/gapic_v1/__init__.py", line 18, in from google.api_core.gapic_v1 import config File "/home/pi/my_venv/lib/python3.7/site-packages/google/api_core/gapic_v1/config.py", line 23, in import grpc File "/home/pi/my_venv/lib/python3.7/site-packages/grpc/__init__.py", line 23, in from grpc._cython import cygrpc as _cygrpc – g3holliday Jun 12 '21 at 17:19
  • ImportError: /home/pi/my_venv/lib/python3.7/site-packages/grpc/_cython/cygrpc.cpython-37m-arm-linux-gnueabihf.so: undefined symbol: aes_hw_encrypt – g3holliday Jun 12 '21 at 17:20
  • That is the full venv error. I'm sorry about the broken error, but it wouldn't let me put it all in one comment :) – g3holliday Jun 12 '21 at 17:21
  • 1
    I see, so if this error persists even in the virtual environment and without all those extra libraries installed, it's most likely a problem stemming from the Raspberry Pi. Since at this point your environment should be exactly the same as my successful run, save for the Raspberry Pi. I would recommend trying to run this somewhere else, possibly in a small Compute Engine instance. You can turn it off after testing if cost is an issue – Yael Araizaga Jun 14 '21 at 22:37
  • I burned a whole new Raspbian OS and tested it, and it worked. I think it was because I had an old OS, and because of that, I had an old `cryptography` library installed. Thank you everyone so much for your time. Merry Making! – g3holliday Jun 15 '21 at 16:52
  • Cryptography's latest version is `cryptography` 3.4.7. I had 2.6.1, which makes sense, since the error was `undefined symbol: aes_hw_encrypt`. – g3holliday Jun 15 '21 at 16:56

1 Answers1

-1

cryptography lib was old. Thanks to everyone who helped!

g3holliday
  • 21
  • 9