0

I have 2 Python files, one is runner.py and other is IntegrationV10.py and some other Excel files for storing intermediate data. In one folder I have all the above mentioned files.The runner.py file runs a infinite loop and inside the loop it calls IntegrationV10.py file every second.

The code for runner.py is given below:

...
while True:

    try:

        os.system("python IntegrationV10.py")
        time.sleep(1)

    except KeyboardInterrupt:

break

I want to bundle runner.py , IntegrationV10.py and all the Excel files to a simple exe file. For this I run the below command:

pyi-makespec runner.py IntegrationV10.py
pyinstaller runner.spec

The exe file is created in dist folder and runs. But it shows error that:

There is no file named IntegrationV10.py

The above message shows every time the runner.exe runs. I could not bundle IntegrationV10.py and excel files in the same exe file. However, when I copy paste IntegrationV10.py and excel files in the dist directory as runner.exe, it starts working. But I want to bundle them all together, not copy paste. Please help me.

2 Answers2

0

See the documentation for pyi-makespec. You need to give it the name of a file that already exists. In other words, pyi-makespec runner.py IntegrationV10.py fails because "IntegrationV10.py" doesn't exist (or can't be found).

In your post, you alternate between "Integration10.py" and "IntegrationV10.py". If you replace pyi-makespec runner.py IntegrationV10.py with pyi-makespec runner.py Integration10.py, does the command work?

user697473
  • 2,165
  • 1
  • 20
  • 47
  • 1
    -thanks @ user697473 . it was a typing mistake. the actual name of the file is IntegrationV10.py. I edited the question once again. please have a look. The runner.exe works if I copy paste IntegrationV10.py and excel file in the same folder as runner.exe. otherwise not. How can I bundle all the files :runner.py, IntegrationV10.py, and excel files altogtaher in single exe file so I don't need to copy paste? – Sharmin Sultana Sheuly May 12 '20 at 16:44
  • "The runner.exe works if I copy paste IntegrationV10.py and excel file in the same folder as runner.exe. otherwise not." That makes sense. Can you edit your post to tell us about your folder structure -- the folder in which "runner.exe" is held, the folder in which the other files are held, and the relationship between those two folders? If you can do that, I think that it will be easy to find an answer. – user697473 May 12 '20 at 17:11
  • 1
    Thanks @ user697473 I edited the question. The answer to your comment is: all the files (runner.py, IntegrationV10.py, excel sheets) all are held in same folder. when I create exe file, a dist FOLDER is created and runner.exe resides in that folder. However, when I run the exe it shows the error message "There is no file named IntegrationV10.py". It solves if I copy paste IntegrationV10.py in the dist folder. However, I wanted to bundle both runner and IntegrationV10.py in the same exe file so that I don't need to copy paste. – Sharmin Sultana Sheuly May 13 '20 at 10:53
0

Instead of

pyi-makespec runner.py IntegrationV10.py

try this if you are using Windows:

pyi-makespec --add-data "IntegrationV10.py;." runner.py

Or try this if you are using Mac/Linux:

pyi-makespec --add-data "IntegrationV10.py:." runner.py

This SO post is helpful.

To also add Excel files to the bundle, something like

pyi-makespec --add-data "IntegrationV10.py;." --add-binary "*xlsx:." runner.py

should work. See https://pyinstaller.readthedocs.io/en/stable/spec-files.html#adding-binary-files for details.

user697473
  • 2,165
  • 1
  • 20
  • 47