[Road to intermediate Python] Install packages in bulk with pip

Link to summary

https://qiita.com/ganariya/items/fb3f38c2f4a35d1ee2e8

Introduction

In order to study Python, I copied a swarm intelligence library called acopy.

In acopy, many interesting Python grammars and idioms are used, and it is summarized that it is convenient among them.

This time, I will talk about batch installation and export of Python packages.

pip

pip is the official Python package manager. You can easily install third-party libraries with pip only.

Older languages can be very cumbersome to install this library Python pip Nodejs npm It is very convenient to have a package manager.

Load package

By using pip

pip install library name

You can install the library in the form of.

However, for example, when you want to use a repository written by another person in Git You may need a ton of libraries to install.

So, it's called requirements.txt By reading the version name of the library to be used and the text file that wrote the name It can be installed all at once.

requirements.txt


alabaster==0.7.12
Babel==2.7.0
beautifulsoup4==4.8.1
boto==2.49.0
boto3==1.10.1

The contents are as above.

In the directory where requirements.txt exists

pip install -r requirements.txt

You can give it as.

Export package

After loading the package, export the package In other words, it is possible to identify all the packages used in the project so that they can be installed immediately in other environments.

pip freeze

When you type the command

alabaster==0.7.12
Babel==2.7.0
beautifulsoup4==4.8.1
boto==2.49.0
boto3==1.10.1
botocore==1.13.1
cachetools==3.1.1

As mentioned above, the terminal will display the library name and version.

Therefore, all you have to do is output this to a file with a pipe.

pip freeze > requirements.txt

If you put this requirements.txt in the GitHub repository I am happy to be able to install the package more easily.

Finally

I've seen bulk installs of packages.

If you use pipenv, it seems to automatically hit requirements.txt It seems that a file that summarizes the packages will be created. It's very easy, so I'll try to touch it.

References

-Bulk installation of packages using requirements.txt with Python and pip

Recommended Posts

[Road to intermediate Python] Install packages in bulk with pip
Manage python packages to install in containers
Install packages that need to be compiled with Python3 with pip [Windows]
Convert PDFs to images in bulk with Python
A road to intermediate Python
[Road to Python Intermediate] Define __getattr__ function in class
How to run tests in bulk with Python unittest
[Road to intermediate Python] Define in in your own class
Install Python 2.7.9 and Python 3.4.x with pip.
[Road to intermediate Python] Use if statement in list comprehension
Unable to install Python with pyenv
[Road to intermediate Python] Enables comparison operations with original classes
How to install mysql-connector with pip3
[Road to Intermediate] Understanding Python Properties
[Python Windows] pip install with Python version
[Road to Python Intermediate] Call a class instance like a function with __call__
What to do if you can't install pyaudio with pip #Python
Install pip in Serverless Framework and AWS Lambda with Python environment
Try logging in to qiita with Python
Install Pyaudio to play wave in python
[Road to intermediate Python] Use ternary operators
How to work with BigQuery in Python
I want to pip install with PythonAnywhere
scipy stumbles with pip install on python 2.7.8
Install python on xserver to use pip
[Road to intermediate Python] Use lambda expressions
To work with timestamp stations in Python
The road to compiling to Python 3 with Thrift
How to install python3 with docker centos
[Road to intermediate Python] Article link summary
What to do if you can't install with pip in babun environment
[REAPER] How to play with Reascript in Python
How to install pip, numpy in Autodesk MAYA
I wanted to install Python 3.4.3 with Homebrew + pyenv
[Road to Intermediate] Python seems to be all objects
Log in to Yahoo Business with Selenium Python
How to use tkinter with python in pyenv
Error when trying to install psycopg2 in Python
Steps to install your own library with pip
How to deal with "No module named'〇〇'" error in Jupyter Notebook | Install with! Pip!
How to install Python
Installing packages with pip3
How to install pip
How to install python
Error with pip install
Install Voluptuous with Python 2.5
Install python with pyenv
Install scikit.learn with pip
How to convert / restore a string with [] in python
What to do if pip install fails in Xcode 5.1
How to do hash calculation with salt in Python
Explain in detail how to make sounds with python
Convert the image in .zip to PDF with Python
Super Primer to python-Getting started with python3.5 in 3 minutes
I was addicted to scraping with Selenium (+ Python) in 2020
I want to work with a robot in python.
Start numerical calculation in Python (with Homebrew and pip)
Until you install TensorFlow-GPU with pip in Windows environment
[Python] Road to a snake charmer (5) Play with Matplotlib
Make it easy to install the ROS2 development environment with pip install on Python venv
Connect to BigQuery with Python