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

旧城冷巷雨未停 提交于 2020-01-14 09:37:06

问题


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:' '

回答1:


I have got similar error when I use "\\" in the path on windows system. like below:

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

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

I have faceed similar problem.I believe its problem with type of slash "/","\".

When i was having code like below :

py_compile.compile('E:\\python_coe\\PythonInput.py','wb') i got similar error when i changed to py_compile.compile('E:/python_coe/PythonInput.py','wb') it worked for me.




回答2:


For me, the first tweak worked.

  1. Try running the command prompt in the admin mode.
  2. Try re-installing pywin32


来源:https://stackoverflow.com/questions/30884768/errno-22invalid-moderb-or-filename-while-running-a-spec-file-while-usin

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!