0

I have been trying to package a python program I have developed with pyinstaller but the main problem is that my program needs to read some data from a directory and I don't know how to adapt the .spec file to read it. In this question is explained how to do it, but for me it doesn't work. The fact is that inside of the folder there are different notepad documents and my program needs to read data from them. I have tried to put the relative path to the folder to add all the documents but it doesn't work. Nowadays my .spec file is:

# -*- mode: python -*-

block_cipher = None


a = Analysis(['run.py'],
             pathex=['C:\\Users\\Desktop'],
             binaries=[],
             datas=[ ('instances\\datA1', '.') ], #datA1 is the name of the document I want to integrate, either in the root of the program in one folder
             hiddenimports=[],
             hookspath=[],
             runtime_hooks=[],
             excludes=[],
             win_no_prefer_redirects=False,
             win_private_assemblies=False,
             cipher=block_cipher)
pyz = PYZ(a.pure, a.zipped_data,
             cipher=block_cipher)
exe = EXE(pyz,
          a.scripts,
          a.binaries,
          a.zipfiles,
          a.datas,
          name='run',
          debug=False,
          strip=False,
          upx=True,
          runtime_tmpdir=None,
          console=True )

How I can integrate all the elements of the folder (not py documents, txt for example) inside the package and later read information from them?

A.Piquer
  • 414
  • 9
  • 23
  • Are you sure the files aren't being packaged and your executable isn't trying to access them from an incorrect path? – import random May 08 '18 at 22:51
  • @Eric the console says that no such file or directory 'instances\\datA1'. I don't know either the document aren't added or the console is going through a bad path. – A.Piquer May 09 '18 at 07:37
  • 2
    I answered a similar question here: https://stackoverflow.com/questions/48611188/how-to-package-an-application-with-dependent-files-by-using-pyinstaller/48627655#48627655 How are you referencing your external files? – apogalacticon May 10 '18 at 00:01
  • @apogalacticon I am referencing as the same way as usual. I thought the fact of adding a folder would mean the same as working in python in a normal way. I have read that the pyinstaller runner froze the system and maybe this is my problem, the program can't access the folder because the program is frozen. – A.Piquer May 10 '18 at 09:52
  • The external files that you save in the `datas` list in the .spec file are saved in a temporary folder that you need to reference using the method described in the link mentioned above. – apogalacticon May 10 '18 at 15:19
  • @apogalacticon I have already done and now I can access the documents. Now the problem is that the .exe is getting me the error: Qt platform plugin "windows". Do you know how to solve it? – A.Piquer May 10 '18 at 15:21
  • It would be helpful to see the complete error message. Because this problem appears to be unrelated to the one asked above, I would recommend opening a new question and providing the full error message. – apogalacticon May 10 '18 at 15:23

0 Answers0