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?
You can do a
In the local machine. And in the server,
This installs all the dependencies
yes there is an command for doing that , once you want to deploy you can generate the package file using the following command:
and whenever you want to install the packages from same file use:
you can find more info about freeze here
I would use pipenv instead of pip. pipenv automatically generate Pipfile and Pipfile.lock that is far superior to requirements.txt
install pipenv and setting it for your project
to install packages from Pipfile is as simple as
Read more https://docs.pipenv.org/
Update: hello to poetry
I have recently moved from pipenv to poetry because poetry has everything pipenv offers and much more. It is end-to-end, as it includes building and publishing of your project to pypi.
installing poetry
and set .poetry/bin in your path.
Like pipenv this generate pyproject.toml file that context all your requirements. Like Pipenv, to install your depence poetry install.
See more:https://poetry.eustace.io/docs/
See Python packaging war: Pipenv vs. Poetry for short review of these awesome packages
Yes, you can put your packages in a simple text file
requirements.txt
, e.g. (version numbers are optional)and then do
pip install -r requirements.txt