This could happen if you have multiple versions of Python installed on your computer. For example you have a package installed on Python 3.5 but you run your script on Python 3.8. On cmd or Powershell you could try something like py -3.8 -m pip list or py -3.5 -m pip list to check which libraries you have installed on each version of Python. Then if the library is missing from the version that you used on your script you can install it specifically for this version using something like py -3.5 -m pip install library_name.
Can you help with a definitive answer for MAC and PC.
I have come across similar questions to this quite a lot on stackoverflow where a user will be using an editor such as IDLE or ATOM and they will get the module not found error, then they will go to terminal or command line prompt and try to pip install the module, and it will either install the module or say requirement already satisfied.
On returning to the editor and running the script it will still give the module not found error.
I have seen the same question, but often asked about for specific modules.
This error started happening a lot for me when I was required to install anaconda for a course and was required to use other editors, but had previously been using a download of Python and working with IDLE.
I often go between a MAC and a PC, where I have got the same issue, where I have an instance of anaconda installed and another instance of python installed.
It is very confusing how to untangle the different paths where some have modules and other don't.
Could someone give some advice on how to rectify this?
I wonder if there is a solution where I could do a pip install that would globally update all versions of python with a module?
module not found even after pip install