0

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.

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

2 Comments

I have not imported second.py in main.py
if your two scripts are not interacting (one using the other) than you have to build two exe.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.