(Aug-04-2021, 02:56 PM)RobertAlvarez424 Wrote: Question , are there two type of exe's for python. One that would run in the dos type environment and one that would run in windows 10 desktop using an icon. May be a while before I attempt doing an exe.
No there is one
.exe
,can have multiply version(python 2.7, 3.8 or 3.9 but the name is still the same
python.exe
.
Windows see Python trough
Environment Variables Path.
For install look at
Python 3.9/3.8 and pip installation under Windows
So the version use most should be in Path,test both
python
and
pip
.
I use
cmder if wonder about
λ
.
# Test python
G:\div_code
λ python -V
Python 3.9.5
# Path to .exe
G:\div_code
λ python -c "import sys;print(sys.executable)"
C:\python39\python.exe
# Test pip
G:\div_code
λ pip -V
pip 21.1.3 from c:\python39\lib\site-packages\pip (python 3.9)
Quote:Does not like spaces in file name.
Use double quote if run command line in Windows.
# test code.py
import os
clear = lambda: os.system('cls')
clear()
i = 1
while i < 6:
print(i)
i += 1
aTuple = (10, 20, 30, 40)
a, b, c, d = aTuple
print(a)
print(b)
print(d)
So if run with this file name
test code.py
need to this.
G:\div_code
λ python "test code.py"
1
2
3
4
5
10
20
40
G:\div_code
Making .exe of this code with
pyinstaller.
Have delete
os.system('cls')
and add last
input("Press enter to Exit")
G:\div_code\dist
λ pyinstaller --onefile "test code.py"
112 INFO: PyInstaller: 4.5
112 INFO: Python: 3.9.5
190 INFO: Platform: Windows-10-10.0.19041-SP0
192 INFO: wrote G:\div_code\test code.spec
.....
G:\div_code
λ cd dist
G:\div_code\dist
λ ls
build/ dist/ 'test code.exe'* 'test code.spec'
# Run exe
G:\div_code\dist
λ "test code.exe"
1
2
3
4
5
10
20
40
When make
.exe
should definitely not use space in file name because the from command line have to use
"test code.exe"
,
this is confusing for end users of the
.exe
.
Quote:one that would run in windows 10 desktop using an icon.
Here comes
file associations into the pictue,should point to main version as shown from command line in my case Python 3.9.