Python Errno 22:invalid mode('rb') or filename:' ' 使用 pyinstaller 运行规范文件时

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/30884768/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-19 09:07:23  来源:igfitidea点击:

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

pythonpyinstallerioerror

提问by darklord777

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

回答by Dawny33

For me, the first tweak worked.

对我来说,第一个调整奏效了。

  1. Try running the command prompt in the admin mode.
  2. Try re-installing pywin32
  1. 尝试在管理员模式下运行命令提示符。
  2. 尝试重新安装 pywin32

回答by Laxman G

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

当我在 Windows 系统的路径中使用“\\”时,我遇到了类似的错误。像下面这样:

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/').

... 而不是那个 pathex=['C:/Python27/PyInstaller-2.1/final_code']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.

py_compile.compile('E:\\python_coe\\PythonInput.py','wb')当我改为py_compile.compile('E:/python_coe/PythonInput.py','wb')它对我有用时,我遇到了类似的错误。