install python.exe using a flash drive - python

I have just acquired a stand alone PC running XP, and I do not want to connect to the internet. I am running python 2.7 on my laptop and was wondering if there was a way to install the python.exe file to a flash drive so I can install python 2.7 on the stand alone. The download from the python.org website goes straight to the path in my c drive, and will not let me save it to the flash drive. I have tried installing from active state, and I am unable to use this as it is not win32. Any help will be much appreciated.

You can download python's zip file then unzip it onto your flash drive, here's the link for the latest release of python 3.6.1 with win32 including all the components that python is required to run as well as the python.exe that you wanted:
https://www.python.org/ftp/python/3.6.1/python-3.6.1-embed-win32.zip
Here's the link to the downloads page, if you wanted another version of python, look for Download Windows x86 embeddable zip file.

If you want a clean, standard CPython installation without bells and whistles on your offline Windows XP machine, you can use your flash drive to transport a Python 2.7 installer from python.org to your Windows XP machine's local hard drive, and then run the installer from there. It could be somewhere between inconvenient and difficult to install third-party packages (as you would find on PyPI) without the full benefit of pip. (Depending on the specific packages you want, you may be able to transport installers or wheels and still use pip in offline mode, without automatic dependency installation.)
If you want a full-featured but potentially big "portable" installation that you can just plop into any directory and use from there, you can try an old version of Portable Python (the project is defunct but the download page is still up as of this writing) or WinPython (note that this answer suggests sticking with 2.7.9 or earlier).

Related

How to compile a python script into executable program and can be use by others

My python script is finished and working and I want to compile and have other users enjoy/benefit from it. The users don't need to install Pycharm or Visual Studio Code, something like an executable file or run in a command prompt then execute on their local machine or is there a way to convert it on a Tampermonkey Script?
How do I achieve this? Thank you very much in advance!
Googled and Youtubed but it's not what I'm looking for.
This question is probably answered multiple times, but the PyInstaller module is a great way to generate an executable that will run on Windows, and an app that will run on macOS.
Check out PyInstaller on PyPI.org: https://pypi.org/project/pyinstaller/
Project description
PyPI PyPI - Python Version Read the Docs (version) PyPI - Downloads
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.
Documentation:
https://pyinstaller.org/
Code:
https://github.com/pyinstaller/pyinstaller
PyInstaller reads a Python script written by you. It analyzes your code to discover every other module and library your script needs in order to execute. Then it collects copies of all those files – including the active Python interpreter! – and puts them with your script in a single folder, or optionally in a single executable file.
PyInstaller is tested against Windows, macOS, and GNU/Linux. However, it is not a cross-compiler: to make a Windows app you run PyInstaller in Windows; to make a GNU/Linux app you run it in GNU/Linux, etc. PyInstaller has been used successfully with AIX, Solaris, FreeBSD and OpenBSD, but is not tested against them as part of the continuous integration tests.
Main Advantages
Works out-of-the-box with any Python version 3.7-3.11.
Fully multi-platform, and uses the OS support to load the dynamic libraries, thus ensuring full compatibility.
Correctly bundles the major Python packages such as numpy, PyQt5, PySide2, PyQt6, PySide6, wxPython, matplotlib and others out-of-the-box.
Compatible with many 3rd-party packages out-of-the-box. (All the required tricks to make external packages work are already integrated.)
Works with code signing on macOS.
Bundles MS Visual C++ DLLs on Windows.
Installation
PyInstaller is available on PyPI. You can install it through pip:
pip install pyinstaller
Requirements and Tested Platforms
Python:
3.7-3.11. Note that Python 3.10.0 contains a bug making it unsupportable by PyInstaller. PyInstaller will also not work with beta releases of Python 3.12.
tinyaes 1.0+ (only if using bytecode encryption). Instead of installing tinyaes, pip install pyinstaller[encryption] instead.
Windows (32bit/64bit):
PyInstaller should work on Windows 7 or newer, but we only officially support Windows 8+.
Support for Python installed from the Windows store without using virtual environments requires PyInstaller 4.4 or later.
Note that Windows on arm64 is not yet supported. If you have such a device and want to help us add arm64 support then please let us know on our issue tracker.
Linux:
GNU libc based distributions on architectures x86_64, aarch64, i686, ppc64le, s390x.
musl libc based distributions on architectures x86_64, aarch64.
ldd: Console application to print the shared libraries required by each program or shared library. This typically can be found in the distribution-package glibc or libc-bin.
objdump: Console application to display information from object files. This typically can be found in the distribution-package binutils.
objcopy: Console application to copy and translate object files. This typically can be found in the distribution-package binutils, too.
Raspberry Pi users on armv5-armv7 should add piwheels as an extra index url then pip install pyinstaller as usual.
macOS (x86_64 or arm64):
macOS 10.15 (Catalina) or newer.
Supports building universal2 applications provided that your installation of Python and all your dependencies are also compiled universal2.
Usage
Basic usage is very simple, just run it against your main script:
pyinstaller /path/to/yourscript.py
For more details, see the manual.
Untested Platforms
The following platforms have been contributed and any feedback or enhancements on these are welcome.
FreeBSD
ldd
Solaris
ldd
objdump
AIX
AIX 6.1 or newer. PyInstaller will not work with statically linked Python libraries.
ldd
Linux on any other libc implementation/architecture combination not listed above.
Before using any contributed platform, you need to build the PyInstaller bootloader. This will happen automatically when you pip install pyinstaller provided that you have an appropriate C compiler (typically either gcc or clang) and zlib’s development headers already installed.
Support
Official debugging guide: https://pyinstaller.org/en/v5.6.2/when-things-go-wrong.html
Assorted user contributed help topics: https://github.com/pyinstaller/pyinstaller/wiki
Web based Q&A forums: https://github.com/pyinstaller/pyinstaller/discussions
Email based Q&A forums: https://groups.google.com/g/pyinstaller
Changes in this Release
You can find a detailed list of changes in this release in the Changelog section of the manual.

Are unofficial python binaries safe?

I was working a on python project in vscode in which I have need to install PyAudio but pip method isn't working so I found the method of unofficial python binaries for windows but I have a doubt are those binaries safe for my PC? Is that going to corrupt files or OS? Do they access data or hardware? or They send some data or enter viruses? or Is there any other method to install pyaudio?
No - a program from anywhere can be unsafe
Your only assurances are
ability to inspect the source code and compile the program yourself
threat of lawsuit (value of compromising your system compared with the value of the source company)
restricted environments (JavaScript, airgapped system)
If you can't guarantee at least one is true, you're very likely at risk
Preferably do not use any software from unreliable sources. It may harm your system.

any known way to create a device-to-device portable self-contained python runtime?

I want to distribute a python program on, say, Windows and/or Mac, but I don't want to give the user the headache of ensuring there is an appropriate python runtime installed on their machine. And i don't want to interfere with their machine's configuration by, let's say, requesting root privileges and installing a system-wide python runtime on their system that suits my program specifically because it's too invasive and might cause compatibility collisions with other installed versions of the runtime.
I would much rather have a self-contained executable that could be, for example, stored on a USB flash-drive, inserted into the system, and then maybe with a stepping-stone binary executable that just invokes the device-portable runtime on a python script that I provide, I could then run the program as if it were a self-contained binary executable (with only standard-library dependencies).
A link to this binary executable could be published into main-menu program lists, docks, or desktops. And it could be invoked by shell scripts or other executed-by-proxy mechanisms. Such a no-install/self-contained python program could potentially be a first-class user-invokable application. This is what I want to achieve.
I googled around for projects that provided a device-portable/mobile python installation and so far I've only found portablepython.com. Unfortunately it says the project is discontinued and no download link for the project is provided. it listed some similar projects but they all seemed defunkt or with a very different focus.
Does anyone know of an active project that is or includes such an independent/portable/mobile/no-install distribution for python?
or is there some way i could configure python's build system to build a noinstall-friendly product?
any ideas welcome. thanks for your input!
After more searching I found that Python.org publishes its own standalone-python distribution called the embeddable zip file.
This is exactly what I was searching for. It's a basic python standalone runtime that requires relatively few megabytes of storage.
I started with this embeddable distro and then cajoled a standalone copy of pip to work with it. Problem solved.
Improving upon #oreus2020's answer, you can download the embeddable zip file from here. Then, unzip the compressed file to a folder of your choice. Go to the root of your install and find python._pth file and open it in a text editor. Remove the "#" before import site(This file is the one which manages the environment of the portable install. If you want anything to be recognized by the portable python interpreter, just throw the path in here and that's it!). If you want pip, go to this page and save it in the root of your portable install and run it using the portable python interpreter like ./python get-pip.py from a commandline opened at the root of your install. Pip installed! To use the pip, do ./python -m pip <commands> from the commandline opened at the root of your install and then open the python._pth file and insert the following below the "." ./Lib/site-packages ./Scripts. Voila, you got yourself a python portable install!
My python._pth file looks like:
python39.zip
.
# Uncomment to run site.main() automatically
./Repo
./Repo/Code
./Repo/Code/cogs
./Lib/site-packages
./Scripts
import site
If you are still wondering, here is the link to the one I made for myself.
P.S. Pardon my bad English

Python 3.4.x Install Via TGZ on Windows 10

I searched this and it's always about Linux operating systems and I'm unable to see any videos or tutorial sites.
I have windows 10 64x based os and I plan to use Python 3.4.x (https://www.python.org/downloads/) for me to use the old cx_freeze (https://sourceforge.net/projects/cx-freeze/files/4.3.3/) since I have this video tutorial in youtube I am currently following https://www.youtube.com/watch?v=XHcDHSWRCRQ which is a python 3 tutorial to create exe file.
The latest cx_freeze file uses .whl files that is so inconvenient for me and I won’t be able to follow the youtube tutorial mentioned above to create a .exe file for my python, thus went on the old cx_freeze that works https://sourceforge.net/projects/cx-freeze/files/4.3.3/ where latest version is for python 3.4. The tutorial on the video has the same cx_freeze process to create a .exe file even if it's for python 3.2.
Also, I don't see any installer of Python 3.4 on it's official page but TGZ files only. I searched about how to use TGZ files on Windows but it's just about extracting and nothing else, while other tutorials on how to install it are all linux based.
How do install it?
This legacy Python website has official downloads for 3.4.0 including a Windows installer. You should be able to grab the .msi from there and that will fix your issue!

How does mercurial work without Python installed?

I have Mercurial 1.3 installed on my Windows 7 machine. I don't have python installed, but Mercurial seems to be OK with that.
How does it work?
Also, is it possible to force Mercurial run on IronPython and will it be compatible?
Thank you.
The Mercurial windows installer is packaged using py2exe. This places the python interpreter as a DLL inside of a file called "library.zip".
On my machine, it is placed in "C:\Program Files\TortoiseHg\library.zip"
This zip file also contains the python libraries that are required by mercurial.
For a detailed description of how mercurial is packaged for windows, see the developer page describing building windows installer.
Since there is a "library.zip"(9MB), Mercurial's Windows binary package maybe made by py2exe, py2exe is a Python Distutils extension which converts Python scripts into executable Windows programs, able to run without requiring a Python installation.
Others have answered the first question -- let me give a guess about the second part.
Mercurial will normally use some C extensions for speed. You cannot use those with IronPython.
But we also ship pure Python versions of these modules, and depending on how much IronPython implements of a standard Python 2.4 environment, those modules could be compatible. I have seen reports on IRC about Jython (the Java port of Python) being able to do a few operations using the pure modules. You should download Mercurial and take a look at the mercurial/pure folder. These modules simply has to be moved up one directory level to be found, the setup.py script can do this if you pass the --pure flag. Please see its source or come talk with us on the Mercurial mailinglist/IRC.
Mercurial bundles the necessary python binaries within it, I believe.

Categories

Resources