So I want to send my python script to another computer, nonetheless, it doesn't have the same package installed on it. Is there any way to send the whole python code as a folder which will also include all that packages? ( I have tried creating a virtual environment through the problem relies on the fact that a lot of the code in the virtual environment is made of aliased files which might not exist on the other computer). Thank you very much in advance for your help.
-
You have a `requirements.txt` file – Jun 04 '18 at 17:08
-
@Tobias what do you mean – Nazim Kerimbekov Jun 04 '18 at 17:08
-
1https://pip.readthedocs.io/en/1.1/requirements.html – tripleee Jun 04 '18 at 17:18
-
Possible duplicate of [How to make a Python script standalone executable to run without ANY dependency?](https://stackoverflow.com/questions/5458048/how-to-make-a-python-script-standalone-executable-to-run-without-any-dependency) – phd Jun 04 '18 at 17:21
-
@phd Not really the same, OP wants to send the "code", not to run it independently. Could be for a colleague to review it. – anishtain4 Jun 04 '18 at 17:32
2 Answers
you can make a requirements.txt
file, here will be all your packages from your project, if you have already vitualenv for example to create your requirements.txt
execute
pip freeze > requirements.txt
example of requirements.txt
absl-py==0.2.1
amqp==2.3.1
asn1crypto==0.24.0
after this take your all project without your virtualenv, copy to another compure create a new virtualenv, enter in your virtualenv and make
pip install -r requirements.txt
you will have all your packages

- 7,171
- 2
- 28
- 38
-
Oh I see, what I wanted to know if there is a possibility to directly send everything in a folder? (also is it a good idea to transfer virtual env folders from one computer to an other) Thank you very much – Nazim Kerimbekov Jun 04 '18 at 17:10
-
2no is a bad idea to transfer your virtualenv folder from one computer to another – Druta Ruslan Jun 04 '18 at 17:11
Barring the longer process of creating an installable package with a setup.py
file, you can place your script in its own folder, then add a pip requirements file. While your virtualenv is active, run the bash/terminal command:
pip freeze > requirements.txt
Ensure that you send the requirements file with the script, and then the recipient can simply run the bash/terminal command (in their own virtualenv, which they hopefully will do)
pip install -r requirements.txt
before running the script.

- 355
- 1
- 10
-
-
thank you very much for your answer, does a setup.py automatically installs all the files? – Nazim Kerimbekov Jun 04 '18 at 17:14
-
@Fozoro: Yes, but it's not really intended for standalone scripts since it installs a package in the active python environment. I don't think it would suit your needs in this situation. – cosmicFluke Jun 04 '18 at 17:17
-
oh I see so if you were to sell a python script you would just send the requirements.text file and the .py files? or you would also send the virtualenv folder? – Nazim Kerimbekov Jun 04 '18 at 17:18