Reputation: 1
I am very new to Python/programming, having recently installed Python 3.10. I have already installed the Openpyxl module, i.e. when I check on CMD I get this:
C:\Users\hadam>pip install openpyxl
Requirement already satisfied: openpyxl in c:\users\hadam\appdata\local\programs\python\python310\lib\site-packages (3.0.9)
Requirement already satisfied: et-xmlfile in c:\users\hadam\appdata\roaming\python\python310\site-packages (from openpyxl) (1.1.0)
I am trying to run some code which I have just copied from here (i.e. I have just edited the file path names): https://www.geeksforgeeks.org/python-how-to-copy-data-from-one-excel-sheet-to-another/
However, when I try to run this script (via the Mu editor), I get the following error message:
Traceback (most recent call last):
File "c:\users\hadam\appdata\local\programs\python\python310\scripts\test1.py", line 2, in <module>
import openpyxl as xl;
ModuleNotFoundError: No module named 'openpyxl'
>>>
Can anyone tell me why the Mu editor cannot find Openpyxl, or what I can do to execute this programme?
Thanks
Upvotes: 0
Views: 845
Reputation: 11
Maybe the error is because Openpyxl does not support Python 3.10 build yet. Check the pypi page for supported versions.
Upvotes: 1
Reputation: 2484
The simple way to resolve this problem is to install a module in Mu Editor. Mu Editor provides its own way to install third-party modules.
How to install third-party modules on Mu editor: https://codewith.mu/en/tutorials/1.1/pypi
In addition, this kind of problem usually happens when there is more than one version of pythons.
# you can check what version of python will be executed on Prompt by typing:
C:\Users\hadam>python --version
On Mu Editor, there is [REPL] button on the top menu. If you click the button, a new terminal will be open at the bottom. Then, the current version of python will be printed on the terminal. (see https://codewith.mu/en/tutorials/1.1/python)
Or, you can type the same command on the Terminal to check a version of python on Mu Editor.
In [1]: python --version
Now, compare the two versions of python, they might be different from each other. Meaning that the module is installed but for another version of python.
Upvotes: 0
Reputation: 2013
Try to open python from the command line, e.g.
C:\users\you> python
or
C:\users\you> python3
or
C:\users\you> path\to\python
then when python is open
>>> import openpyxl as xl
If the problem is not present anymore, your Mu editor might be using a different python interpreter/environment: check for its configurations and change it to the one you opened from the terminal.
Upvotes: 0