Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to automatically install required packages in Python?

In Node.js, for a project we create a package.json file, which lists all the dependencies, so that NPM can automatically install them.

Is there an equivalent way to do this with Python ?

like image 332
Rahul Iyer Avatar asked Dec 13 '22 18:12

Rahul Iyer


2 Answers

Node has npm similarly python having pip

pip is a package management system used to install and manage software packages written in Python.

So first you need to install pip,

sudo apt-get install python-pip

You have to keep your requirements in requirements.txt in you project folder as like package.json in nodejs.

eg:

pip install package1
pip install package2
pip install package3

Then move on to your project path, then do this:

pip install -r requirements.txt
like image 57
Mohideen bin Mohammed Avatar answered Dec 16 '22 07:12

Mohideen bin Mohammed


You can use pip freeze > requirements.txt to generate dependencies list, and use pip install -r requirements.txt to install all dependencies.

like image 41
Hou Lu Avatar answered Dec 16 '22 08:12

Hou Lu