首页  >  问答  >  正文

python - pyinstaller无法在命令行运行,提示failed to create process.

$ pip install pyinstaller

后运行:

$ pyinstaller -F 文件

pyinstaller无法在命令行运行,会提示报错:

failed to create process.
黄舟黄舟2741 天前1181

全部回复(2)我来回复

  • PHPz

    PHPz2017-04-17 17:53:04

    我了解了一下感觉上应该是 pip 的一个 bug Spaces in Python path make pip-installed launchers fail on Windowspip 的一個 bug Spaces in Python path make pip-installed launchers fail on Windows


    原因分析:

    簡單來說就是 shebang line (script 裡面指定 python path 的那一行) 裡面有空白導致的,可能就是安裝 Python 的路徑上有空白而且 pip 在安裝的時候沒正確幫你加上引號,例如你的 Python 在:

    C:\Program Files (x86)\Python35-32\python.exe
              ^     ^           
              空白惹事

    然後用 pip

    原因分析

    :


    简单来说就是shebang line (script 里面指定python path 的那一行) 里面有空白导致的,可能就是安装Python 的路径上有空白而且pip 在安装的时候没正确帮你加上引号,例如你的Python 在:

    #!C:\Program Files (x86)\Python35-32\python.exe  <-- 這個 shebang line 有問題,因為空白
    # EASY-INSTALL-ENTRY-SCRIPT: 'PyInstaller==3.1.1','console_scripts','pyinstaller'
    然后用 pip 安装的 Pyinstaller 的 script 里面对于路径上的空白没有正确的用 引号

    处理好:

    #!"C:\Program Files (x86)\Python35-32\python.exe"  <-- 這個 shebang line 有問題,因為空白,我們補上前後的引號
    # EASY-INSTALL-ENTRY-SCRIPT: 'PyInstaller==3.1.1','console_scripts','pyinstaller'

    以上是原因

    解决办法🎜:🎜 🎜有一些 workaround 的方式可以解决,第一个是你直接去 pyinstaller 的 script 里面利用引号把空白问题给搞定(在 Python 目录下的 Script 子目录下):🎜
    C:>"C:\Program Files (x86)\Python35-32\python.exe" "C:\Program Files (x86)\Python35-32\Scripts\pyinstaller-script.py" script_to_compile.py
    🎜或是直接用 Python 运行 script (不透过 shebang line 了):🎜 rrreee 🎜我查到还有人用一招,重装 Python 在路径没有空白的地方(笑),真的也是一招。 🎜

    回复
    0
  • 阿神

    阿神2017-04-17 17:53:04

    你还在Windows上用Python?而且还不用Conda?

    快看这篇文章
    [原] 容器定义应用:数据科学的容器革命

    回复
    0
  • 取消回复