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
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.)
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
Supposing you have python 2.x
on the path under python2
you can do
python2 -m pyinstaller hello.py
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
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