简体   繁体   中英

How to automatically install the most common python packages?

I'm getting tired or installing the same 20 or 30 python packages all the time. Is there an off the shelf way to batch install all the most common python tools in one go? I know I can write my own bash script, but I would prefer something curated that I don't have to maintain by myself.

Automatically install the most common packages ? No.*

  • * (I suppose someone could write a script which checks pypi's stats and downloads & installs them but you'd still need to run the script for each fresh install.)

Semi -Automatically install a certain set of packages ? Yes.

  1. Make a new folder and create a file called requirements.txt (or anything you prefer).
  2. In it, list all the packages you want.
    • Start with those 20-30 packages you mentioned, perhaps with version numbers.
    • Details on the format of the file here .
  3. Then run python -m pip download -r requirements.txt .
    • This will only download the packages to the current folder, not install them.
  4. Copy that folder to a USB drive
  5. for each new Python install, open a command prompt, go to the folder and type python -m pip install -r requirements.txt .
  6. You could even put those two commands in separate batch ( .bat ) files or shell scripts. So you can just 'double-click' them to execute.
  7. And once a week, or whatever cycle you like, run the first command to get the latest versions and then run the command: python -m pip install --upgrade -r requirements.txt .

(Another option):

  • Copy-paste a long command like python -m pip install package1 package2 package3... packageN for each new install.

PS. You almost never actually need all those many packages, and should use a Virtual Env per project.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM