Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Errno 22:invalid mode('rb') or filename:' ' while running a spec file while using pyinstaller

This is my spec file

# -*- mode: python -*-
a = Analysis(['final_code.py'],
             pathex=['C:\\Python27\\PyInstaller-2.1\\final_code'],
             hiddenimports=[],
             hookspath=None,
             runtime_hooks=None)
pyz = PYZ(a.pure)
exe = EXE(pyz,
      Tree('C:\\Python27\\data_req\\'),
          a.scripts,
          exclude_binaries=True,
          name='final_code.exe',
          debug=False,
          strip=None,
          upx=True,
          console=False )
coll = COLLECT(exe,
               a.binaries,
               a.zipfiles,
               a.datas,
               strip=None,
               upx=True,
               name='final_code')

I have modified it to include the text files required. I am running it using the below command

pyinstaller.py final_code.spec

in my command prompt.

The error I get is

[Errno 22] invalid mode('rb') or filename:' '
like image 433
darklord777 Avatar asked Jun 17 '15 07:06

darklord777


1 Answers

I have come across a similar error when I use "\\" in the path on a Windows system.

Example:

a = Analysis(['final_code.py'],
             pathex=['C:\\Python27\\PyInstaller-2.1\\final_code'],
           ....
exe = EXE(pyz,
      Tree('C:\\Python27\\data_req\\'),

Instead of that the double slash, try pathex=['C:/Python27/PyInstaller-2.1/final_code'] and Tree('C:/Python27/data_req/').

I believe the issue is with the type of slash being used: "/" vs "\".

py_compile.compile('E:\\python_coe\\PythonInput.py','wb') gave me the same error, but changing it to py_compile.compile('E:/python_coe/PythonInput.py','wb') worked for me.

like image 80
Gautam Avatar answered Nov 14 '22 23:11

Gautam