ImportError: cannot import name ‘open’ from ‘smart_open’ error occurs when the “smart_open library is not installed or not installed correctly.”
How to fix it?
To fix the ImportError: cannot import name ‘open’ from ‘smart_open’ error, “install the ‘smart_open’ library”.
pip install smart_open==6.3.0 # OR conda install smart_open==6.3.0
The smart_open is a Python 2 & 3 library for efficiently streaming large files from/to S3, HDFS, WebHDFS, or local (compressed) files. It is well-tested (using Moto), well-documented, and sports a simple Pythonic API.
An alternate way is to upgrade the smart_open library using this command:
pip install smart_open --upgrade
If you still get the error after updating smart_open and checking that it is installed correctly, you may need to uninstall and reinstall smart_open. You can do this by running the following commands in your terminal:
pip uninstall smart_open pip install smart_open
This should fix the error.