If you see this error when trying to import pandas under osx 10.14 Mojave
ModuleNotFoundError: No module named '_lzma'
You may be missing the xz
libraries (https://tukaani.org/xz/)
This may be corrected by using homebrew to install it.
brew install xz
You then need to rebuild the Python you are using with pandas.
If you happen to be using pyenv
then you can run
pyenv uninstall 3.6.4 # Replace with your version number
pyenv install 3.6.4 # Reinstall (now with the lzma lib available)
pyenv local 3.6.4 # Set this version to always run in this directory
pip install pandas
You should now be able to import pandas!
CFLAGS="-I$(brew --prefix xz)/include" LDFLAGS="-L$(brew --prefix xz)/lib" pyenv install 3.11.7
this worked for me.