Home  >  Q&A  >  body text

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

$ pip install pyinstaller

后运行:

$ pyinstaller -F 文件

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

failed to create process.
黄舟黄舟2742 days ago1188

reply all(2)I'll reply

  • PHPz

    PHPz2017-04-17 17:53:04

    I learned about a bug that seems to be pip 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

    Cause analysis

    :


    To put it simply, it is caused by the blanks in the shebang line (the line in the script that specifies the python path). It may be that there are blanks in the path to install Python and pip did not add it correctly for you during installation. Upper quotes, for example your Python is in:

    #!C:\Program Files (x86)\Python35-32\python.exe  <-- 這個 shebang line 有問題,因為空白
    # EASY-INSTALL-ENTRY-SCRIPT: 'PyInstaller==3.1.1','console_scripts','pyinstaller'
    Then use pip to install Pyinstaller's script. The spaces in the path are not used correctly. Quotation marks

    are handled well:

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

    The above are the reasons

    Solution🎜:🎜 🎜There are some workarounds to solve the problem. The first one is to go directly to the script of pyinstaller and use quotation marks to solve the whitespace problem (in the Script subdirectory of the Python directory): 🎜
    C:>"C:\Program Files (x86)\Python35-32\python.exe" "C:\Program Files (x86)\Python35-32\Scripts\pyinstaller-script.py" script_to_compile.py
    🎜Or run the script directly using Python (not through the shebang line):🎜 rrreee 🎜I found out that someone else used a trick, reinstalling Python so that there is no blank space in the path (laughing), it is really a trick. 🎜

    reply
    0
  • 阿神

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

    Are you still using Python on Windows? And you don’t need Conda?

    Read this article quickly
    [Original] Container Definition Application: Container Revolution for Data Science

    reply
    0
  • Cancelreply