3

Is it possible to run virtualenv projects on machines without Python installed? I'm developing an app on a Ubuntu machine and want to run it on a Windows machine that doesn't have Python (or any library, such as virtualenv) installed.

Could I conceivably use virtualenv to develop on the Ubuntu machine, then just run the application on the Windows machine without installing Python/virtualenv?

Ash
  • 97
  • 1
  • 8
  • I believe that the answer here can help: https://stackoverflow.com/questions/5539736/python-can-i-run-a-python-script-without-actually-installing-python – Marco Giuseppe de Pinto Mar 18 '18 at 21:24
  • No; `virtualenv` just manages *which* Python installation is used to run code. In the extreme, it installs a version of Python in your virtual environment directory. In no way is it capable of running Python code itself. – chepner Mar 18 '18 at 21:24
  • There are third-party tools to build a "portable virtualenv", but that's only portable to other systems of the same platform. The only way what you want could possibly work is if it included a Python interpreter for every platform in the universe (or at least every platform supported by current CPython). – abarnert Mar 18 '18 at 21:25
  • Python.exe would be different on Linux & Windows. Virtualenv will use the system installation to start with and make a local setup. What I do is, I create an executable on Linux & Windows and then distribute it or in some cases use the Python installation from a central location and use the source code. – sarbjit Mar 18 '18 at 21:26
  • A better solution might be building a container (or a general-purpose VM image) that includes a minimal linux installation, including Python and your virtual environment. But then you still need to install a runner for that container (or VM) on Windows. – abarnert Mar 18 '18 at 21:27
  • Or you can build a Windows installable application and copy _that_ over to your Windows box. I'm not sure if there are any tools to cross-build such a thing from linux, but there might be. – abarnert Mar 18 '18 at 21:28
  • @abarnert I need exactly that use case (sharing python scripts to other Windows users that don't have Python installed), but I can't find any "portable virtualenv". Do you know any? – ABO Jul 09 '21 at 13:02

0 Answers0