result below:
Traceback (most recent call last):
File “C:\Users\ADMIN\PycharmProjects\ExcelSpreadsheets\app.py”, line 1, in
import openpyxl as xl
ModuleNotFoundError: No module named ‘openpyxl’
Looks like the python and pip you are using are in different locations on your machine.
Is the project operating in a virtual environment? It looks like it may not be…
To sort this out, it would be helpful to reconfirm which instance of both python and pip you are using - specifically which locations are these installed in.
Looks like you are on Windows, so using a terminal, navigate to your project directory which seems to be “C:\Users\ADMIN\PycharmProjects\ExcelSpreadsheets” from your initial question.
Then run these commands “where python”, which should return the path of the python you are using… then run “where pip” which should return another path for pip. These two paths should point to the same base location, although the result for pip will have a suffix of “/Scripts/pip” on Windows. It is likely that the problem is that your openpxl is installed into a python in a different location.
To fix, I recommend you create a virtual environment for your project which is pretty easy:
“python -m venv venv” – which uses the venv module to create a virtual environment named venv, which will be a new directory inside your project directory.
“venv\Scripts\activate” – “activates the virtual environment” which contains essentially a local instance of python and pip for the project (not really, but that is the basic effect).
now install your project dependencies into this new venv - like openpyxl, and whatever else you are using…
If you activate and work within this venv every time you work on this project, you should avoid the error you saw before. After activating the venv, you can check the path of python and pip the same way described above, and the paths returned should both point to a path inside this venv.