Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Single command in python to install relevant modules from a package.json like file

Tags:

python

pip

In node.js, one can do npm update --production during deployment and all the relevant node.js modules will be installed as long as the right package.json is in place.

Is there a python equivalent command line for easy deployment? Can pip do the same thing as npm?

like image 884
guagay_wk Avatar asked Nov 17 '15 07:11

guagay_wk


People also ask

Which command is used to install any module or package in Python?

You can install modules or packages with the Python package manager (pip). To install a module system wide, open a terminal and use the pip command. If you type the code below it will install the module. That will install a Python module automatically.

How do I install a specific module in Python?

To install a specific version of a Python package you can use pip: pip install YourPackage==YourVersion . For example, if you want to install an older version of Pandas you can do as follows: pip install pandas==1.1.

How do I add a module to a package json?

To add dependencies and devDependencies to a package. json file from the command line, you can install them in the root directory of your package using the --save-prod flag for dependencies (the default behavior of npm install ) or the --save-dev flag for devDependencies.


1 Answers

yes there is an command for doing that , once you want to deploy you can generate the package file using the following command:

pip freeze > requirements.txt 

and whenever you want to install the packages from same file use:

pip install -r requirements.txt 

you can find more info about freeze here

like image 179
Allen Fernandes Avatar answered Sep 30 '22 01:09

Allen Fernandes