8

i have installed many python modules plugins and libraries in my centos system. Now i don't want to install each thing again on separate computers.

Is there any way i can make the package like rpm or any other thing so that when i install in in new location all the modules, dependencies also gets installed and everytime i install new thing i can update the install package

Mirage
  • 30,868
  • 62
  • 166
  • 261

2 Answers2

10

If you have installed the packages with pip (an improved easy_install), you can just do pip freeze > my-reqs.txt to get a list and versions of the installed packages. There is also some option to install using the reqs file:

pip install -r my-reqs.txt

Pip is meant to companion virtualenv, which can be used to handle per project requirements of dependent packages.

Pedram
  • 921
  • 1
  • 10
  • 17
peterhil
  • 1,536
  • 1
  • 11
  • 18
  • 1
    Pip may also work when the packages are installed by other tools. – peterhil Jun 03 '11 at 06:55
  • so u mean it will get all the list of things installed either by pip , easy install , rpm or tar.gz – Mirage Jun 03 '11 at 08:01
  • Apparently it finds out the installed packages from the shell environment variable $PYTHONPATH that you can set in your shell’s startup file – eg. .bashrc for Bash or .zshrc or .zshenv for Zsh. There is also PYTHONSTARTUP env variable where you can set Python specific stuff. – peterhil Jun 03 '11 at 08:15
  • Be sure to include your package manager installed Python’s site-packages/ dir before the system provided Python, if on Mac OS X. The $PYTHONPATH syntax is the same as for $PATH – separated by colons. – peterhil Jun 03 '11 at 08:20
  • 1
    You can also do `pip install --install-option="--prefix=$PREFIX_PATH" package_name` to install into different lib. See http://stackoverflow.com/questions/2915471/pip-how-do-i-install-a-python-package-into-a-different-directory – peterhil Jun 03 '11 at 08:22
  • i got the list of installed modules but how will install all on other computer provided i installed python in same folder. i have gone through so much headache by providing various lib path. i don't want to repeat it again – Mirage Jun 03 '11 at 15:12
  • 1
    I think you don't necessarily need to set the paths on the new machine, just do `pip install -r my-reqs.txt`, IF you only have one Python installation. You could set the paths just to be sure, especially, if you later decide to install Python somewhere else. – peterhil Jun 03 '11 at 18:22
  • in my windows, i have installed PyQt5 and few other mods which are not listed by pip freeze. – Kaymatrix Sep 23 '17 at 16:19
  • @KumaresanLakshmanan See my other answer for the situation without using Pip: https://stackoverflow.com/a/46382325/470560 – peterhil Sep 23 '17 at 17:24
1

If you are not using Pip, then you should check what packages you have in your global and/or user site-packages directories.

The solutions below are from:
How do I find the location of my Python site-packages directory?

Global site packages:

python -m site

or more concisely:

python -c "import site; print(site.getsitepackages())"

User site packages:

python -m site --user-site

The latter do not however show the site-packages of the current virtual environment – use distutils.sysconfig.get_python_lib() for that:

python -c "from distutils.sysconfig import get_python_lib;
print get_python_lib()"

Note! You can not just copy over the packages that have C++-extensions or other compiled binaries in them. These have to be reinstalled on other machines.

peterhil
  • 1,536
  • 1
  • 11
  • 18