grpc import error for python embed in c++

25 views
Skip to first unread message

pradeep....@gmail.com

unread,
Jul 9, 2019, 9:55:29 AM7/9/19
to grpc.io
Hi,

I have Ptython module developed around google Speech to Text client library (Python).
I am interfacing to this module from my C++ application. (Embedding python in C++ application).
Getting import related error (Please find at the end) while loading module.

Please let me know, what I am doing wrong or missing something in setup, 

Setup:
      Using python 3.6
      OS: CentOS 7
      Installation:  
              yum install python36u
              pip install --upgrade google-cloud-speech              


Error Log:

Traceback (most recent call last):
  File "/root/env/stt_interface.py", line 2, in <module>
    from stt_google import speechToText
  File "/root/env/stt_google.py", line 10, in <module>
    from google.cloud.speech import types
  File "/usr/lib/python3.6/site-packages/google/cloud/speech.py", line 20, in <module>
    from google.cloud.speech_v1 import SpeechClient
  File "/usr/lib/python3.6/site-packages/google/cloud/speech_v1/__init__.py", line 17, in <module>
    from google.cloud.speech_v1.gapic import speech_client
  File "/usr/lib/python3.6/site-packages/google/cloud/speech_v1/gapic/speech_client.py", line 23, in <module>
    import google.api_core.gapic_v1.client_info
  File "/usr/lib/python3.6/site-packages/google/api_core/gapic_v1/__init__.py", line 16, in <module>
    from google.api_core.gapic_v1 import config
  File "/usr/lib/python3.6/site-packages/google/api_core/gapic_v1/config.py", line 23, in <module>
    import grpc
  File "/usr/lib64/python3.6/site-packages/grpc/__init__.py", line 23, in <module>
    from grpc._cython import cygrpc as _cygrpc
ImportError: /usr/lib64/python3.6/site-packages/grpc/_cython/cygrpc.cpython-36m-x86_64-linux-gnu.so: undefined symbol: PyExc_ImportError


Thanks,
Pradeep

Lidi Zheng

unread,
Jul 9, 2019, 1:13:09 PM7/9/19
to grpc.io
The error seems caused by the binary unable to find the Python shared library in your system.
The Python version you install is "36u", but the ".so" file you are importing is built for "36m".

The suffix means that the CPython binary is built with different flags, and has different ABI.
The "u" means wide-unicode, and "m" means "pymalloc". See https://www.python.org/dev/peps/pep-3149/#proposal

You may want install the exact same version of Python, or compile by yourself.

pradeep....@gmail.com

unread,
Jul 10, 2019, 9:07:30 AM7/10/19
to grpc.io
Thanks Lidi,
I forgot to mention one setup state i.e. installation of 36u development package. I have installed it before installing google speech package
yum install python36u-devel.x86_64

When I installed '36u' package and google speech package,  libraries and ".so' related to "36m" are also get installed.
'PyExc_ImportError' defined in file 'pyerrors.h' file and file installed at /usr/include/python3.6m/pyerrors.h
Still while importing it unable to find it
Reply all
Reply to author
Forward
0 new messages