Mayank Jain
Mayank Jain

Reputation: 67

Python: executable not running correctly

What is the correct command of pyinstaller to successfully build .exe file from python project.

I've tried below commands but not working in my case.

Project
|--->main.py
|--->second.py
|--->images (folder)
      |--->image.jpg

Above is my project structure. I have given main.py to pyinstaller command.

pyinstaller --noconfirm --onedir "main.py" --console --log-level "DEBUG" --add-data "images/image.jpg;." --add-data "second.py;."

Exe is generated from above line and also runs but when it calls second.py it shows error that modules not found. As both python files uses same modules.

I've also tried using virtualenv and given path of it.

pyinstaller --noconfirm --onedir "main.py" --console --log-level "DEBUG" --add-data "images/image.jpg;." --add-data "second.py;." --paths "venv/Lib/site-packages" --paths "venv/Lib"

This don't even run exe.

Upvotes: 0

Views: 168

Answers (1)

Eric Mathieu
Eric Mathieu

Reputation: 631

Remove --add-data "second.py;." from your build command. If your second.py script is imported in your main than pyinstaller will find it. --add-data is for data, not program.

Upvotes: 1

Related Questions