I installed openpyxl from the command line with pip. I am trying to run the code:
import openpyxl
from openpxyl import Workbook
I get: ModuleNotFoundError: No module named 'openpyxl'
. This happens even though openpyxl shows up in the list of installed packages that comes up with pip list
.
What I have tried so far:
- Uninstalling and re-installing openpyxl with pip3. This question says that I should be able to use
pip3 install openpyxl
, but using that gets anERROR: No matching distribution found for openpyxl
. I was only able to get it to install if I usedpip3 install --user openpyxl
- Confirming I have the most recent version of pip with
pip install --upgrade pip
. - Confirmed that the location of the site package is listed with
print(sys.path)
. - Trying to manually add the location of the site package with:
sys.path.append("C:/Users/[myname]/AppData/Roaming/Python/Python310/site-packages/")
And with:
sys.path.append("C:/Users/[myname]/AppData/Roaming/Python/Python310/site-packages/openpyxl/")
- Confirming that I have no other versions of Python installed as in this question.
- Setting up a virtual environment, installing openpyxl with
pip3 install openpxyl
in that, activating the virtual environment, and then invoking the script from that environment.
All of the above result in the same error.
CodePudding user response:
It is workbook
, not Workbook
.
And the error is in this line: from openpyxl import workbook
, not in import openpyxl
line.
Also close your old terminal where you just installed the package.
Demo:
Just installed package in a terminal for you:
and in a new terminal (works!):