I have encountered this error yesterday which I've already resolved by installing the missing optional dependency. But today as I started another Python file in PyCharm I'm getting the same error again.
ImportError: Missing optional dependency 'xlrd'. Install xlrd >= 1.0.0 for Excel support Use pip or conda to install xlrd.
Does anyone knows why this might be happening?
I tried again now to install it and pip confirmed that it's already installed.
C:\Users\Ben>pip install xlrd
Defaulting to user installation because normal site-packages is not writeable
Requirement already satisfied: xlrd in c:\users\ben\appdata\roaming\python\python37\site-packages (2.0.1)
I think what's going on here is that xlrd
is installed in your user wide site-packages
but pycham uses different virtual environments for every project. This probably means that xlrd
isn't installed in your project's virtual environment. You can try doing the following in your terminal:
.\venv\bin\activate
Now you should see the name of your virtual environment in braces in your shell. Something like this - (venv)C:\path\to\project>
pip install xlrd
You can read more about virtual environments here