I have a script that I wrote in Python. It uses some libraries such as Twython that allows me to post pictures and text to twitter. Now I am trying to make my own photo-booth that runs on Windows. I wish to run the script on the windows computer and I do not wish to install Python on the Windows machine.
I have tried to make exectuables but they do not work (I think because I have inputs that need run after the script (python script.py Message filepath). I thought there was a way to include everything of a normal Python install in the folder you run your script from and it will allow me run it cross platform.
Edit: My question is how can I package python up to run with out installing it preferably from a folder on the desktop.
Related
For test purposes,
I tried to install Blender as a Python module in a virtual environment with Python 3.7 to be sure that i can use bpy.
I follow this page for the installation (https://wiki.blender.org/wiki/Building_Blender/Other/BlenderAsPyModule)
I would like at the end, when I wrote a Python script who used blender command to be able to run outside Blender software and to get information when my script finish
So I have multiples questions:
I don't really understand this line of command for Windows and how I can adapt to my virtual environment :
xcopy /E bin\2.81 C:\Python37\2.81
I can't use 'import bpy' command even when I successfully do pip install bpy in the command line ?
For my final goal project, I'm afraid that it's impossible to do because I couldn't find examples or questions related to my project.
Can someone could explain a little if it's possible or interesting to use Blender externally ?
What is the simplest tool to convert a python script into an executable file?
I made a python script and requirements.txt which contains necessary packages for a virtual environment with python3.6. I gave them to my client so that he can create a virtual environment and execute the file by executing the three lines below in the console.
source activate
python __main__.py
deactivate
Basically he needs to run it once a day, so that my python script scrapes a stock index data release at the end of each day and does some data transformation and saves the data in a desired directory as excel files.
However my client told me "even the three lines are difficult for people who are not familiar with CUI. Can you make it like a clickable icon?"
Is there any tool that can easily package my python script and required packages as an executable file or icon? It doesn't have to be cool. A simple and primitive tool would serve our needs. My client has Windows 10 Pro 64bit but it has to be something that I can develop in my My work environment which is Mac OS Catalina.
Thank you!
Yes, it is possible following library's help with this.
PyInstaller can be used, under Mac OS X, Windows, Linux,...
For an example i would read this medium post, it should contain everything to get you started.
py2exe can be used if you only want an executable for the Windows platform.
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 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 want to start using Python at work, and I have a script that I need all the end users to run on a central network drive.
However, they don't have admin rights to install Python and I am not going to call desktop support and go through that mess. I'm thinking of putting my WinPython installation on the network, pointing to the py.exe in a BAT file, and instruct users to run the BAT file.
Is there a better way to do this?
I ended up using WinPython and that suited my needs nicely. It's a convenient little package.
http://winpython.sourceforge.net/
Have you tried using py2exe or Pyinstaller? Pyinstaller converts python scripts to standalone executables that can be run on windows, linux, and Mac OS.
Here's the link to their wiki page on github: https://github.com/pyinstaller/pyinstaller/wiki