ImportError: cannot import name 'cygrpc' from 'grpc._cython'
Issue details
I'm seeing the following error in my Formant agent logs:
ERROR Media encoder: python3 uncaught exception
5月 17 16:06:51 formant-agent[5837]: Traceback (most recent call last):
5月 17 16:06:51 formant-agent[5837]: File "/usr/lib/formant/agent/media_encoder_main.py", line 16, in <module>
5月 17 16:06:51 formant-agent[5837]: from media_encoder.media_encoder import ( # noqa: E402
5月 17 16:06:51 formant-agent[5837]: File "/usr/lib/formant/agent/media_encoder/media_encoder.py", line 6, in <module>
5月 17 16:06:51 formant-agent[5837]: import grpc
5月 17 16:06:51 formant-agent[5837]: File "/usr/lib/formant/agent/dist-packages/grpc/__init__.py", line 23, in <module>
5月 17 16:06:51 formant-agent[5837]: from grpc._cython import cygrpc as _cygrpc
5月 17 16:06:51 formant-agent[5837]: ImportError: cannot import name 'cygrpc' from 'grpc._cython' (/usr/lib/formant/agent/dist-packages/grpc/_cython/__init__.py)
Troubleshooting steps
Codename matching
Check that the codename in cat /etc/os-release
matches the codename for the formant entry in cat /etc/apt/sources.list
.
- If not, change
sources.list
to matchos-release
. Then run the following commands:
sudo apt remove -y formant-agent
sudo apt update
sudo apt install -y formant-agent
Python version
Check that your Python version is the default for your Linux distribution.
- Run the following command:
python3 --version
Default Python versions:
- Bionic: 3.6.9
- Focal: 3.8.10
If your Python version does not match the default for your distribution:
- Install the default version and add to
/var/lib/formant/.bashrc
- Run:
export FORMANT_AGENT_PYTHON3_PATH=<</path/to/correct/python>>
- Restart your agent.
Updated 12 months ago