0

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?

silver
  • 13
  • 3
  • Define "won't let you install anything". If you can copy files to the server somehow, then copying a complete Python into one of the folders you own works just as well as it does under Windows. – Tomalak May 05 '22 at 07:28

4 Answers4

1

I've built stand alone executables using pyinstaller. It works well. I've only used it to deliver into Linux so far.

Paul Whipp
  • 16,028
  • 4
  • 42
  • 54
  • I thought about this idea, but since the people who use this tool are programmers in the company, they sometimes modify the source code. This could be a good alternative if I don't find a suitable method – silver May 05 '22 at 07:37
  • If you use the pyinstaller 'one folder' options, programmers can tweak the source within the limits of the requirements but you are probably better off installing python to your home folder. This rarely violates admin policies - you can't do much if you can't install stuff to your home folder. See https://pages.github.nceas.ucsb.edu/NCEAS/Computing/local_install_python_on_a_server.html for the general approach. – Paul Whipp May 05 '22 at 07:57
0

Yes, you can use python docker images for running python scripts.

rok
  • 9,403
  • 17
  • 70
  • 126
0

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.

cao-nv
  • 184
  • 4
  • *"you cannot run a Python script directly without the interpreter installed."* - the emphasis is on *directly* (i.e. by making the script executable). Nothing stops you from copying the interpreter into your home directory and then calling it explicitly as `/path/to/my/private/python /path/to/my/file.py`. – Tomalak May 05 '22 at 07:30
  • Sure, in case there is an interpreter installed somewhere it can be called your way. In my answer, I assumed that there was no Python installed in the environment. – cao-nv May 05 '22 at 07:37
  • ???The idea sounds so cool. – silver May 05 '22 at 07:43
0

This answer is to leave some reference for the subsequent people who encounter the similar situation.

silver
  • 13
  • 3