How to change python version for use with pyinstaller

后端 未结 5 945
遥遥无期
遥遥无期 2021-02-06 00:25

I am trying to convert a .py file to an exe. My file, hello.py, reads:

print \"Hello, World!\"

I am currently trying to use pyinstaller. Howeve

相关标签:
5条回答
  • 2021-02-06 01:16

    When you need to bundle your application within one OS but for different versions of Python and support libraries – for example, a Python 3 version and a Python 2.7 version; or a supported version that uses Qt4 and a development version that uses Qt5 – we recommend you use virtualenv. With virtualenv you can maintain different combinations of Python and installed packages, and switch from one combination to another easily. (If you work only with Python 3.4 and later, python3 -m venv does the same job, see module venv.)

    • Use virtualenv to create as many different development environments as you need, each
    • with its unique combination of Python and installed packages.
    • Install PyInstaller in each environment.
    • Use PyInstaller to build your application in each environment.
    0 讨论(0)
  • 2021-02-06 01:18

    Using Python3:

    Make sure PyInstaller is installed in Python 3.x: pip3 freeze

    PyInstaller==3.3.1

    Then running the command:

    /path/to/python3 -m PyInstaller your_script.py
    
    0 讨论(0)
  • 2021-02-06 01:28

    Supposing you have python 2.x on the path under python2 you can do

        python2 -m pyinstaller hello.py
    
    0 讨论(0)
  • 2021-02-06 01:29

    First install Pyinstaller in your python2.7 version if not installed previously py -2 -m pip install pyinstaller

    and then go to your folder and

    py -2 -m pyinstaller -F filename.py
    
    0 讨论(0)
  • 2021-02-06 01:31

    I ran two a couple things. If you uninstall python3, it works with python2. If you have python3 installed (and it is the primary), and have pyinstaller installed in python3, it wont work (python3 pyinstaller used). If you have python3 installed, but do not have it installed in python3 or uninstalled it (pip3 uninstall pyinstaller), pyinstaller works.

    Checking the environmental variables (windows 10) PATH had python3 first. This may be the issue and may not be resolved because it is checking python3 directories first, and picks up pyinstaller for python3. pyinstaller does not check the file either (#!/usr/env/bin python2).

    Unless pyinstaller puts an option relating to this issue, there may be no solution short of uninstalling pyinstaller from python3 temporarily.

    note could also use py2exe, using py2exe for python2, pyinstaller for python3

    0 讨论(0)
提交回复
热议问题