0

I'm running pyinstaller from cmd to create an exe from a script I wrote in a Pycharm Venv.

I'm using the line:

pyinstaller--onefile main.py

When trying to run my exe I get this error:

    File "main.py, line 2, in <module>
        from playsound import playsound
    ModuleNotFoundError: No module named 'playsound'
    [5624] Failed to execute main

Things I've tried:

  • --hidden-import "playsound"

  • --hidden-import playsound

  • Dragging the exe out of dist and running it in the mainfile

  • attempted to create a hook but I don't really understand what to put in the hook script for playsound?

  • Deleted the other interpreter so there's only one

  • installed pyinstaller in the Venv itself

Tomerikoo
  • 18,379
  • 16
  • 47
  • 61
  • Can you explain me few things like which os you are using and how did you installed playground and pyinstaller...I will try to reproduce the error – Sachin Rajput Dec 12 '20 at 08:41

2 Answers2

1

Have you installed it with pip? pip install playsound

Owen Valentinus
  • 611
  • 4
  • 12
0

You dont have playsound installed I believe, or you have it installed in the wrong env. Try running this in your terminal: pip3 install playsound If you dont have pip installed, this: sudo apt install python3-pip ; pip3 install playsound

Mysterious K
  • 79
  • 2
  • 8
  • This worked, does that mean whoever wants to run my program needs to have locally installed playsound? Or do all modules also need to be installed outside of my venv in order for pyinstaller to work? – Modern Sunrise Dec 12 '20 at 08:58
  • @ModernSunrise If you want others to use your program, they need to have the dependencies installed. What you can do is compile it into an executable file, run this in your terminal `pip3 install pyinstaller ; pyinstaller --onefile yourFileName.py` – Mysterious K Dec 12 '20 at 10:28