Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I run a Python project on another computer without installing anything on it?

I have a Python Project that has a bunch of dependencies (in my VirtualEnv). I need to run my project in my school computer for Demonstration. My School computer does not have python installed, and lets assume also wont have an Internet connection to install it. I have written the program in Windows 10, and the school computer runs Windows 7.

I have looked at these solutions so far, and also here is why I think they may not work.

  1. Copy and pasting my virtual Env - Doesnt work because venv's have their own structures and has my username in its paths which it will look for in the other system.
  2. Using Py2Exe. I have an Exe file, that I can now run on other systems running Windows 10 without them having python or any of my packages. But I am not sure the VC++ dependencies will be present in windows 7. It may also have some other weird issue that I cant risk.
  3. Docker. I am not familiar with Docker, but can do it if this happens to be the only way.

How can I run the python file in that computer?

Also note that I will not have the time to mess around in the other system. Ideally I must plug in my USB and Open the file to run it. If you think there isn't a solution to this, please let me know by telling so.

Thanks!

like image 696
Krishnaraj PT Avatar asked Mar 26 '21 17:03

Krishnaraj PT


People also ask

Can you run python files without installing python?

py2exe is a Python extension which converts Python scripts (. py) into Microsoft Windows executables (.exe). These executables can run on a system without Python installed. It is the most common tool for doing so.

How can I use python without installing anything?

Use py2exe or one of the other exe builder utils for python on windows. On other platforms just use the python script. Show activity on this post. This program can freeze your python code into a .exe file and some other pyd files, it can be run without installing python.

How can someone else run my python script?

You can use py2exe (windows), py2app (Mac OS X) or cx_freeze to convert your application to an executable. cx_Freeze is cross platform and should work on any platform that Python itself works on. Show activity on this post. You need to convert it to an executable.


Video Answer


3 Answers

I see two options.

  1. Use an online IDE and Python Interpreter (assuming you did not have internet for downloading Python, but do have internet in general). I suggest replit.

  2. Use a portable version of Python. Those are available in the official website and are called "Windows embeddable package". You can test downloading it to a usb, and running it in some computer without Python; it should work.

like image 174
miquelvir Avatar answered Oct 23 '22 14:10

miquelvir


You can use PyInstaller to generate an exe file from your code. It runs without installation.

Or you have a look at the WinPython distribution which is portable and comes with several tools and packages pre-installed.

Note that Windows 7 only supports Python up to version 3.8. 3.9 is only supported on Windows 10 and will silently fail to run without giving you any hint.

like image 39
MP24 Avatar answered Oct 23 '22 14:10

MP24


Try python as a portable version.

  • Download the python Windows embeddable package(zip package) and extract it to your flash drive. https://www.python.org/downloads/windows/
  • In extracted python folder, press the shift key + right click and select open command window(windows 7) / open powershell window here(windows 10) option.
  • Type './python' and hit the enter key.
like image 1
trueThari Avatar answered Oct 23 '22 15:10

trueThari