python executable file in windows - python

Okay, I'm completely new to this.
I created a python script that imports tkinter. On my Ubuntu, I can execute the program from the terminal program. Till now there is no problem. However, my friends asked if I could deliver the program to them so that they could use it on their PC. They have 0 knowledge of programming and they use Windows -.-. So my question is, how I can create an executable file from Ubuntu so that it can run under Windows? I've already read something about py2exe, but I could not manage installing it. If

You can't use py2exe on plain Ubuntu. It needs to run from Windows. Right now, py2exe doesn't work well with Wine. Do you not have access to any Windows computers (maybe one of your friends')?
You can also get your friends to install Python on their Windows machines and teach them how to run your programs, if you're willing to put in the extra effort.

Related

Is it possible to run python scripts without python installed in Linux?

I once did something similar under windows, copying the whole python and specifying PYTHONPATH by a .bat script to make it work locally.
But today I got a Linux server that has a strict working environment and won't allow me to install anything. And unfortunately I know little about Linux. I wonder is there a similar way that I can run python on the server?
Yes, you can use python docker images for running python scripts.
I've built stand alone executables using pyinstaller. It works well. I've only used it to deliver into Linux so far.
Sorry, I cannot put a comment because of my low reputation.
In short, you cannot run a Python script directly without the interpreter installed. Fortunately, you can install a Python environment without root permission by using Miniconda (or Anaconda), then make a virtual environment and install the required packages to run your code locally for your use only.
This answer is to leave some reference for the subsequent people who encounter the similar situation.
If you choose to package via pyinstaller. Here is a good method. Almost no different from writing python. How to pack a python to exe while keeping .py source code editable?
NOTE: But there is some bad news, such as the glibc version issue. If you encounter this problem, you can refer to Pyinstaller GLIBC_2.15 not found

How to run a makefile - Python - Speciteller

I have a large database of text which i want to analyze on it's sentence specificity. I want to use the tool 'Speciteller' for that, using Python. Link to the tool:
https://github.com/wjko2/Domain-Agnostic-Sentence-Specificity-Prediction/tree/master/python
One of the dependencies is to make sure to have liblinear.so. in the python/ directory. If not, i can execute a makefile - 'type make in /python' . I opened my Anaconda Prompt to execute this command, but it doesn't work. It says it is not recognized as a command, operable program or batch file.
I have already been looking how to specifically execute makefiles in Python, but i have a hard time finding the answer. Does anyone has some advice?
Note: i am still a beginner concerning Python.
Thanks in advance!
EDIT: Bump - anyone has any idea?
Edit: Operating on a Windows system
In the meantime this problem has been solved. A new update was released and additional code was provided to run it in Python smoothly. See the following repository:
https://github.com/wjko2/Domain-Agnostic-Sentence-Specificity-Prediction
A Makefile is a way to describe to a computer the steps of the compilation process of a program. To use a Makefile, on an Unix-like system (Linux, MacOS, etc.) one need to have the program make installed on their computer, and then, in a unix-shell (and not powershell like the anaconda prompt), run the command make.
However Windows does not know natively how to process those files, as the program make is not available by default on Windows. You can use a tool like WSL that let you run command designed for GNU/Linux on Windows. (I recommend installing Ubuntu 18.04). Going this route means that you will probably need to reinstall anaconda inside WSL though.

Simplest way for end users to run Python script on network drive without installation?

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

Is it possible to create a Python program distributable for Windows that can be run from anywhere?

I think my question is quite badly phrased, which may be why I haven't been able to find the answer yet.
I created my program in Python, created an installable .exe file from it using bdist_winisnt. Once the program is installed, I would like to be able to run it from anywhere. It's a command line program, so I would like the user to be able to be in a different directory and still be able to type example.py in command line and the program can run.
Is this possible? Is there a way of including some kind of path instruction in the setup.py which will be run on install so that the computer will always know where it is?
I would also like to be able to do this in Linux at some point, will it work the same?
I'm very new to programming, so I may have made some mistakes with what I have said, apologies in advance.
EDIT: turns out there was a really simple way to do it by adding one line to the setup.py file
Good answer to your question is: http://docs.python-guide.org/en/latest/shipping/freezing/
Options are:
bbFreeze
py2exe (supports Python 3)
pyInstaller (does not support Python 3)
cx_Freeze
py2app (Mac)
Your installer only copies the python script to a specified directory.
In order to run a python script you need to have python installed.
You can use a tool like PyInstaller to convert your script (.py file) into an executable (.exe on windows). The way that works is PyInstaller copies both the python interpretor and your script into a single file so that you can distribuite your program easily.
After you have converted your script into an executable, you need to add it to the path so that your operating system knows where to find it. After you do that, you can run your program from the command line from any directory.
The same process will also work on Linux, but you'd have to make separate distributions of the executable because windows executables are different from linux executables.
Check PyInstaller
PyInstaller is promising solution for creation of executables.
I have tested it on Ubuntu, but documentation claims, MS Windows is supported too.
There are multiple options, one of them being single executable file (which include complete Python).

How to run Python script on Ubuntu, Windows and MAC

I'm making Python software using wx GUI library but was wondering how to run this script on different OS's. For example, do I need to create executable installation file or bat file on Windows and sh file in Ubuntu?
I've got #!/usr/bin/env python at the top of the file and I can seem to run it by actually double clicking it and clicking it on "RUN" on prompt window but I would like it to be more professional as the users are not programmers.
Being used to run python scripts on both linux and Windows environments, I know that you can use the same script for both environments.
Keep using your shebang in Linux, it won't be procesed in windows (as it is actually a comment :).
Once Python is installed in Windows, you can actually simply double click on the script (it will run by default in a cmd window), run it using the cmd or launch it in idle.
If you want to develop python scripts on windows however, you'll need some more tools :).
If you want to be more professional (and prevent your users to modify the code :), you can still think about creating an exe file : http://www.lyxia.org/blog/developpement/python/creez-des-executables-46
(warning, french inside), by using pyinstaller http://www.pyinstaller.org/ . Works for windows and linux

Categories