0

I am new in Python. I would like to write a python script in machine A with Ubuntu OS. After the writing script done, I want to run the script in another machine. I plan to use virtual environment. Is it possible to copy the venv from machine A to machine B directly? My expectation I can execute the script in machine B without doing some package installation anymore. Is it possible?

Anyone can give me an advice or example please. Thank you so much.

Cheries
  • 834
  • 1
  • 13
  • 32
  • 3
    Copying a virtual environment is not recommended. There might be library problems. It is better to create a new environment based on a `requirements.txt`. – Klaus D. Dec 03 '21 at 06:53
  • 1
    Virtual environments are to isolate environments from each other. If you are looking for a deployment solution consider containerization solutions such as docker. – Selcuk Dec 03 '21 at 06:55
  • @KlausD. But if I use `requirements.txt` it means need to install some package. In the B machine there is no internet connection to download the package – Cheries Dec 03 '21 at 07:12
  • 1
    @Cheries There are two approaches. 1) Create a [standalone executable](https://stackoverflow.com/a/12059644/7976758); see also https://stackoverflow.com/search?q=%5Bpython%5D+standalone+executable ; 2) [Download all necessary wheels](https://stackoverflow.com/a/14447068/7976758), copy them to machine B and `pip install` them there; see https://stackoverflow.com/search?q=%5Bpip%5D+offline . – phd Dec 03 '21 at 12:41
  • Since you are new in it, Is Python required? If you want to create a program without needing to download external dependencies, there are better options. – OneCricketeer Dec 03 '21 at 21:39

0 Answers0