-1
pip install tkinter
pip install PIL
pip install openpyxl

I want with one command all of these to be installed on any PC via the command prompt or python shell.

How can I do this?

Bryan Oakley
  • 370,779
  • 53
  • 539
  • 685
Ricky
  • 69
  • 1
  • 7
  • Why do you want that? Are you perhaps planning to package an app for easy distribution? If so, look at e.g. PyInstaller. – AKX May 03 '21 at 08:01
  • 1
    Does this answer your question? [How to install multiple python packages at once using pip](https://stackoverflow.com/questions/9956741/how-to-install-multiple-python-packages-at-once-using-pip) – Ceres May 03 '21 at 08:02
  • 3
    You cannot install `tkinter` using `pip`. – acw1668 May 03 '21 at 08:03
  • when you say PC, do you mean any OS? – jtlz2 May 03 '21 at 08:08

1 Answers1

1

You would just do:

pip install tkinter PIL openpyxl

except that - as acw1668 points out - you cannot install tkinter using pip. So that would then be:

pip install PIL openpyxl

Or you can put them, one per line, in a file called requirements.txt and execute:

pip install -r requirements.txt

As mentioned by Ceres, you can use the following to put currently-installed packages into the file:

pip freeze > requirements.txt

To install from the python prompt, take a look at Installing python module within code

You're still left with the problem of how to install tkinter. Instructions for several different OSs are here: Install tkinter for Python

You could combine the answers and use a subprocess to install python-tk from within python.

PS Consider pillow over PIL:

pip install Pillow
jtlz2
  • 7,700
  • 9
  • 64
  • 114
  • 1
    You can use `pip freeze > requirements.txt` to get all installed packages into the file – Ceres May 03 '21 at 08:01