#πŸ”’ how can i get python to auto install on a computer

22 messages Β· Page 1 of 1 (latest)

dawn trellis
#

im making a game and due to how im making it i DONT want to turn it into an exe
how can i make python auto install

this is my current code using a windows batch file:
@echo off

REM Check for Python installation
python --version >nul 2>&1
IF %ERRORLEVEL% NEQ 0 (
echo Python is not installed. Installing now...

REM Set the URL for the latest Python installer (Python 3.12.0)
SET "python_installer_url=https://www.python.org/ftp/python/3.13.5/python-3.13.5-amd64.exe"
SET "installer_path=%TEMP%\python-installer.exe"

REM Download Python installer using PowerShell
powershell -Command "Invoke-WebRequest -Uri '%python_installer_url%' -OutFile '%installer_path%'"

REM Run the installer
start /wait "%installer_path%" /quiet InstallAllUsers=1 PrependPath=1

REM Clean up
del "%installer_path%"

) ELSE (
echo Python is already installed. please wait
)

REM Launch your game
python main.py

meager sparrowBOT
#

@dawn trellis

Python help channel opened

Remember to:

  • Ask your Python question, not if you can ask or if there's an expert who can help.
  • Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
  • Explain what you expect to happen and what actually happens.

:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.

hallow mica
#

its probably best to just have the user download python, very few people will want another program automatically downloaded onto their computer

ivory halo
dawn trellis
blazing wigeon
dawn trellis
#

making people have to install python would discourage people downloading the game

blazing wigeon
#

And this can also cause issue when the user install a different python

#

Also, does your game have dependency that isn't standard library?(Such as pygame/pygame-ce,textual)

rugged pelican
#

i will preface this with i have never used pyinstaller

https://pyinstaller.org/en/stable/

but this problem is reminding me of pyinstaller, would it work? pithink

PyInstaller bundles a Python application and all its dependencies into a single package. The user can run the packaged app without installing a Python interpreter or any modules.

blazing wigeon
#

Note that pyinstaller also have the tendency of being flagged as malware

rugged pelican
#

ah. i didnt know that oops

blazing wigeon
#

As many more other py to exe generator

blazing wigeon
# rugged pelican ah. i didnt know that oops

Well, as they can be are frequently used to make python malware, and due to the signature of the executable would be similar (as it bundle the interpreter and all the library, which your code is just a very small amount), and arbitrary code execution is possible (which is difficult if not impossible to analysis), which therefore antivirus just flag them

dawn trellis
dawn trellis
low raft
#

try Nuitka

celest blade
# dawn trellis ive tried pyinstaller and it NEVER works

You could try Nuitka.
Also you mention pyinstaller NEVER works. Maybe you forgot to set a hidden import - I know tkinter requires to be hidden imported (I know very annoying). Or you could try the GUI version of pyinstaller called auto-py-to-exe just run that in command line after pip installing and a GUI should appear.

meager sparrowBOT
#
Python help channel closed for inactivity

This help channel has been closed. Feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.