I'm using: Python 2.7 and Pyinstaller 2.1.
I'm able to successfully create a single executable with the -F argument. My script leverages wget to upload a file to a remote server. Let's just say that I need to use either wget or curl to achieve this (I know there are other modules that can accomplish this). This is done via a subprocess call. The problem that I'm having is that whatever Windows machine executes the script, wget/curl must already be installed.
Is there a way, via Pyinstaller, to include the wget binaries? So that the executable contains all the necessities to run the script and utilize wget/curl?
Thank you in advance.
Related
I have to run a shell script on a Centos Linux machine that calls a python file. Inside the python file, there is the following code snippet:
from lib.rclone import Rclone
rclone = Rclone()
if shutil.which("rclone") == None:
print("Rclone executable is missing, install it")`
The problem is that I am not supposed to install any code (including rclone) on the machine. Therefore, whenever I call the shell script, it ends up with the error message. I don't know how can I successfully run it?
The program you are running requires rclone. Since you cannot install it, you cannot run it. Simple as that.
You can try to release the script as a .exe file.
By using pyinstaller (https://pyinstaller.org/) you don't have to install any libs or py package on the target machine, you can even choose to release it as a single executable.
This question already has answers here:
How can I distribute python programs?
(8 answers)
Closed 2 years ago.
I have developed some scripts which I need to share with colleagues who does not have python nor have underlying distributions to run it. How to automatically configure environment and more importantly run the script without even python installed?
I saw some solutions on SO like py2exe. Not sure that it’s the best option. Docker is also not possible since in my case I need something what can work simply by running python3 path/to/program
You can use online coding platforms like repl.it to run scripts from the browser so u don't want to install python locally.
Convert it into a exe file using pyinstaller
Following are the steps:
1. Open cmd on the folder in which you stored your py file
2.type it on the cmd
pyinstaller -- onefile filename.py
If you don't have pyinstaller module then install it using
pip install pyinstaller
It depends on the complexity of the script.
If it is doing complex things that it needs to be run on your computer for, like file input & output, then PyInstaller is probably the way:
pip isntall
pyinstaller -- onefile script.py
If it is just a short script, then Repl.It is a great way to save and share scripts that can be viewed and run right in the browser. It supports installing pip packages and environments. It even has a feature where you can host a terminal app as a website: repl.run
I am using PyInstaller to create a complete standalone executables, that does not depend on a machine having python interpreter. Here is a complete guide: https://datatofish.com/executable-pyinstaller/
I am connected to a machine running Windows 8 from my linux machine using OpenSSH. I need to download python3 on the Windows machine but I only have access to the command prompt, not PowerShell. I also have sftp set up, but all the python downloads are installers which don't work through the command prompt. Does anybody know what I can do?
You can download using the curl program, if it's installed on your windows machine. Something like:
curl https://www.python.org/ftp/python/3.8.3/python-3.8.3-amd64.exe -o python_install.exe
(or look for the Python version you want at https://www.python.org/downloads/windows/)
Then, you can run:
python_install.exe /quiet
There are also zip file packages you can download from the URL above.
Note that a quiet install may not change your system's PATH, so you may need to locate the directory in which Python was installed, and call the program from there.
I want to make a portable app that would have some code and python executable that would run on any Windows even if python is not installed.
I would like it to be python 3.6 and so it has only pip and setup tools installed.
EDIT: concerning duplicate
not quite. I don't want to compile the code. I wanted to give them .py files but realize that Windows won't have python installed on default. I want something that can be carry on a flash drive but will run my code from source not binary.
Please correct me, if I understood it wrong. I think there are at least two ways to do it.
suppose you have one portable_run.py script you want to run everywhere on a flashdisk.
Make a exe file with pyinstaller for example. you can get a exe file like portable_run.exe. On target windows system what you need to do is to run the exe direcltly protable_run.exe
Use a portable python distribution like winpython or python-xy. you just need to copy this portable distribution on the flash disk together with your portable_run.py. To run it on target system flashdisk/path-of-winpython/python portable_run.py
Hopefully it could give you some idea.
I also encountered the same problem and managed to create a portable python with Python's official Windows embeddable package.
I wrote the steps into a ps1 script so I can easily repeat the process without going through the pain.
The steps:
Download the portablepy.ps1 from the repo :
https://github.com/Dreamsavior/portable-python-maker
Create a blank folder, put the portablepy.ps1 to that folder.
Execute the portablepy.ps1
The script will create a portable python 3.9.10 with pip in the current folder by default.
To install custom version of Python run the script with -source and -destination parameter
.\portablepy.ps1 -source "https://www.python.org/ftp/python/3.9.10/python-3.9.10-embed-amd64.zip" -destination "C:\SomeDir\PortablePython\"
Where the -source is the url of the Python's Windows embeddable package from this page: https://www.python.org/downloads/windows/
And -destination is the path of your folder (ended with backslash).
I have a python code which I need to send it to a client who will run it windows.
The python code works on a few imported modules mentioned in requirements.txt:
requests==2.11.1
xlwt==1.1.2
beautifulsoup4==4.5.1
If I have to execute the code in windows, I’ll have manually ask the client to download these above modules before running the script.
I have created a bash script ( for linux), which is such:
sudo pip install -r requirements.txt
echo "Requirements met"
python ./isb.py
What is the bash script equivalent in windows? I want to client to only execute 1 file which executes other remaining files.
Can an executable be made for a task like this?
The code and other files are here if need be.
I has similar task in the past. So I just used a tool py2exe which builds a standalone executable and it resolves dependencies at build time. A valid python interpreter will be included to the build. So your client can just execute this standalone exe file by double-click or from cmd shell.