I tried pyinstaller after reading few tutorials (in a hurry, though) and watching some video tuts. It beautifully made the dist folder which contains the executable file which runs on my ubuntu.
But when copied the same folder on windows 8 system, windows simply doesn't recognize it.
What I want is to make one single file for ubuntu, 1 for windows and 1 for mac such that users click on it and then a few nexts and then it gets installed on the system. A desktop icon should be created for it, just like normal softwares.
How can I do that?
You can't "cross-bundle" with Pyinstaller.
If you want to distribute your application on multiple operating systems, you must install pyinstaller and bundle your app separately on each, as explained on this page
Related
I am writing in Python and trying to export it as a .exe file from Mac machine. I tried to export it by auto-py-to-exe and it works well in my Mac machine. However, I found that it could not be opened in Window even I add the '.exe' after its file name. Is there any way to fix it or I can only export it in a Window machine? Thanks!
auto-py-to-exe seems to be a graphical interface for PyInstaller. According to the official PyInstaller docs
If you need to distribute your application for more than one OS, for example both Windows and Mac OS X, you must install PyInstaller on each platform and bundle your app separately on each.
You can do this from a single machine using virtualization. The free virtualBox or the paid VMWare and Parallels allow you to run another complete operating system as a “guest”. You set up a virtual machine for each “guest” OS. In it you install Python, the support packages your application needs, and PyInstaller.
So you would need to build it on a Windows or Windows VM to get it to work on Windows.
I have just started using python and pycharm, and I have a windows laptop and a mac where I need to work from. In specific, I created a project including a venv in my windows laptop which is uploaded in one drive and works perfectly for that laptop. So my question is; can I work on that same project from my mac?
Instinctively my answer would be no, because all the virtual environment files originally created in the windows venv are .exe which are incompatible with anything mac related. Trying to open the project and load the interpreter myself has confirmed that this doesn't work.
But then I stumbled on to this post, which would suggest that this person can run a project from a windows and linux OS with the only problem being that they only have to re-select the interpreter.
So is there any way that the above can be done, or a workaround at least? (e.g. creating two venvs for each OS or something).
Yes, you can run the same Python code on both Windows and Mac. You will need to create separate virtual environments on each because the Python interpreter is a .exe file on Windows and something else on Mac.
I suggest that you use git to track changes in your code. Then you can push your code to a service such as GitHub so that your changes are avaialble on all of your computers. You won't add the virtual environments to the git repository, though. These should be created separately on each machine where you want to work on your project.
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.
So I can use PyInstaller to make a one-file executable and to make a standard executable among other files in a folder.
But how do I turn Python files into an MSI installer so that it's fool-proof where it makes a shortcut on the desktop? (For distribution so that it isn't required for the user to have Python installed)
(When I say Python files to an MSI installer I mean the regular PyInstaller to folder output but with a way of getting a shortcut to the executable onto the desktop very easily for a regular user)
(It doesn't have to be PyInstaller if there's an alternative).
Pyinstaller does not intergrate such a tool.
You could get a third party installer (some suggested here How to create a robust, minimal installer for Windows?) and add your output exe to it and install that way, if you choose the right tool you will be able to add to desktop (plus a lot of other actions such as adding to path ect).
Or you could use cx_Freeze which has it built in. When running the setup script just add the bdist_msi flag.
It can add to shortcut desktop but is fairly limited in other ways (or you may need to perform some hack).
To add to desktop with cx_Freeze see Use cx-freeze to create an msi that adds a shortcut to the desktop.
You can use Inno which creates a shortcut on the desktop and start menu. Also, it is located in the program directory of windows. it means that you can install/uninstall it like other programs or applications.
Inno website:
https://www.jrsoftware.org/isinfo.php
A tutorial on how to use it on youtube:
https://www.youtube.com/watch?v=DTQ-atboQiI
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