Use Docker to use Py2exe on a Mac - python

I have never before used docker, but I have been developing a python application on a mac and have been told that I could use docker to allow me to run py2exe so that it can be turned into an executable windows application. I have tinkered with a few pre-built scripts to do this and keep running into errors.
My questions are: how can I build a docker container to simulate python 3.6.5 for windows.
How can I install the additional python modules into this container (py2exe and the ones in my python app)
Sorry for throwing out such basic question. I know Docker is super powerful but I really just want to use it for this one thing.

You can use this image for that, but it use PyInstaller instead of Py2EXE
https://hub.docker.com/r/cdrx/pyinstaller-windows
This image has wine installed, which is used to run Windows apps on Linux

Related

How to package Python GUI application into Debian package to run on debian based operating system or any other linux systems?

I have an python GUI application that communicates with a web application, the website generates a link to open the desktop application (python app), so i have bash scripts that modify the system variables to make it ready for the system to recognize the link and open the app,
My question is that i want to make a debian package for that app with the files and bash scripts, how to do it??
I tried to convert the python application into one-file using pyinstaller and put bash scripts in same installer folder then run them using another python application that i compiled also with pyinstaller but the error happened telling that pythonlib3.8 not found on the system (Ubuntu 18) and my app developed on Ubuntu 20.
I would suggest using fpm. This is a tool specifically for creating packages for different Linux distributions such as Debian or RHEL.
Here is the documentation and even specific example for python.

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

Is there a way to turn my python script (that I wrote in an Ubuntu docker image) into an executable for Windows?

Made a python script in Ubuntu, but I read that pyinstaller compiles based on the operating system, so if I compile it on Ubuntu, it'll be for Ubuntu. How can I make an executable in Ubuntu, for Windows, or do I have to export my script into my Windows OS and compile it there?
From PyInstaller’s documentation:
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.
So, yes, you generally must run PyInstaller on the operating system the emitted binary will be run on. The documentation does suggest using a virtual machine and that running PyInstaller with WINE may work.

Can I create .exe file from python project If I am working on mac?

I am working on Mac iOS, but I need to make my whole project as .exe file, not .dmg. It is meant to be running on Windows, I would like to use pyinstaller but I faced some problems, wondering if working on Mac has to be the reason.
PyInstaller has can only target the OS it is running on: Source. However, you could use a VM running Windows to build a Windows executable, or use something like wine (Example here) to package it without a VM.

Use (Linux) virtualenv from Windows

I want to develop a Python application on Windows 7, by using a Linux VM. I would like to make use of the Python interpreter that's inside my VM (virtualenv).
Unfortunately, PyCharm is the only editor that supports the use of a remote interpreter. Is it possible to make use of my virtualenv when using Komodo IDE for instance, without installing local (Windows) libraries?
I have tried VirtualBox shared folders, VMWare shared folders and ExpanDrive, but they all seem a little unstable for this purpose (random operation not permitted errors when creating virtualenv in a shared folder).
Thanks in advance
EDIT: To be specific, I need the site-packages from the virtualenv. When I pip install an app like Django, I would like my IDE to auto-complete imports etc.
Virtualenv on Linux uses bash scripts. These won't work on Windows. The Windows version of virtualenv uses either batch files or the PowerShell. They won't work on Linux. One solution that may work would be to setup the same virtualenv on both Linux and Windows. That is, you have to install all packages twice: once on Linux and once on Windows. Putting your own code on a shared drive should work, unless there are some problems I have not anticipated. ;)
Just ssh into the vm.
Honestly I think the best solution would be to just fullscreen the vm and do it all in there, but that's just me.

Categories