1

I can't seem to get the code running when executed in a windows command prompt (command used: python filename.py) or when it is transferred to exe with pyinstaller. in both these occassions it gives the error code: ModuleNotFoundError: No module named 'plyer. This is odd since I did specify to import the module.

from plyer import notification  #pip install plyer
import time

def notifyMe(title, message):
    notification.notify(
        title = title,
        message = message,
        app_icon = None,
        timeout = 10,
    )


if __name__ == '__main__':
    while True:
        notifyMe("TEST")
        time.sleep(100)
  • Did you verify that running the script via a `cmd` command actually uses the exact same Python environment as the PyCharm project? Usually PyCharm projects have their own virtual Python environment that packages get installed to, and so any packages available there usually aren't available outside of that environment. – Random Davis Apr 19 '21 at 21:49
  • @RandomDavis HA thank you man! I just had to install python -m pip install plyer on the cmd console. know this sounds question sounded very stupid and maybe it was but thank you for taking your time and solving my problem! – Augurkenplukker12 Apr 19 '21 at 22:08
  • Little question if i want to run my pyinstaller's exe to a client who does not have python and (this module) how can I make sure that it still runs? – Augurkenplukker12 Apr 19 '21 at 22:42
  • You need to ask that as a new question, if you truly can't find the answer to that online. It's one question per post here. However the answer, I believe, is quite simple - if the .exe runs on your machine, it'll work on someone else's, since the .exe doesn't require python or any libraries to be installed. More info here: https://pyinstaller.readthedocs.io/en/stable/operating-mode.html – Random Davis Apr 19 '21 at 22:45

2 Answers2

0

I am guessing that you have two versions of python installed; one version used by pycharm, and another configured in your path (since you ran python filename.py).

your pip is probably configured to install to the instance of python which pycharm uses, so you may need to specify the instance of python that is used in the cmd prompt.

check this out to see if it helps:

Install a module using pip for specific python version

Shawn Ramirez
  • 796
  • 1
  • 5
  • 10
  • Little question if i want to run my pyinstaller's exe to a client who does not have python and (this module) how can I make sure that it still runs without running into this problem? – Augurkenplukker12 Apr 19 '21 at 22:44
  • Check out this post; I find it very helpful. https://stackoverflow.com/questions/44210656/how-to-check-if-a-module-is-installed-in-python-and-if-not-install-it-within-t – Shawn Ramirez Apr 20 '21 at 19:17
0

Did you verify that running the script via a cmd command actually uses the exact same Python environment as the PyCharm project? Usually PyCharm projects have their own virtual Python environment that packages get installed to, and so any packages available there usually aren't available outside of that environment - Random Davis

link that helped me if pyinstaller doesn't import all modules: https://www.youtube.com/watch?v=2gu5stlEtms&list=WL&index=1