Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Dependency installation for Python (Django) project

I'm new to Python, but I had a requirement at my work-place. Another programmer is developing a project on Python, Django framework, and my task is to find a way in which this project will be executed at any computer. So, I'm talking about something like Composer for PHP. I need an easiest way that at debian branch to write in terminal a command, that will find kind of "composer.json" file on that project, will read all the required software, modules, libraries and install it step-by-step on PC.

Any ideas how to do it in the easiest way? Thanks.

like image 616
priMo-ex3m Avatar asked Jul 07 '17 11:07

priMo-ex3m


People also ask

Does pip automatically install dependencies?

Pip relies on package authors to stipulate the dependencies for their code in order to successfully download and install the package plus all required dependencies from the Python Package Index (PyPI). But if packages are installed one at a time, it may lead to dependency conflicts.

What is pip install Django?

PIP is a package manager for Python that uses the Python Package Index to install Python packages. PIP will later be used to install Django from PyPI. If you've installed Python 3.4, pip is included so you may skip this section. Open a command prompt and execute easy_install pip . This will install pip on your system.


2 Answers

Since you have not talked about virtual environment, assumed that you already setup the environment and activated it.First get all the libraries lists in requirement.txt file in your project directory by typing below command,

pip freeze > requirements.txt

when you need to setup project in another system just run this

pip install -r requirements.txt

All the dependency will be installed in your project enviornment.

like image 84
Aniket Pawar Avatar answered Sep 22 '22 21:09

Aniket Pawar


Using pip freeze > requirements.txt is an anti-pattern. It does some things right, such as pinning version numbers, but it can lead to problems with orphan packages later.

I use pip-tools, this way only your top level dependencies are placed in your requirements.in file and then I use pip-sync to sync my local environment with pip.

There's a lot more information on pip best practices in my 2016 Pycon UK talk - Avoiding the "left pad" problem: How to secure your pip install process

like image 35
aaronbassett Avatar answered Sep 22 '22 21:09

aaronbassett