• 12

A PHP Error was encountered

Severity: Notice

Message: Undefined index: userid

Filename: views/question.php

Line Number: 191


File: /home/prodcxja/public_html/questions/application/views/question.php
Line: 191
Function: _error_handler

File: /home/prodcxja/public_html/questions/application/controllers/Questions.php
Line: 433
Function: view

File: /home/prodcxja/public_html/questions/index.php
Line: 315
Function: require_once

name Punditsdkoslkdosdkoskdo

PIP: Installing only the dependencies

I have a script that creates a virtualenv, installs distribute and pip in it and then optionally clones a git repo.

Now I have the project I will be working on, installed. But its dependencies are not installed. How can I make pip install all the dependencies as if I have issued a pip install MyApp?

EDIT: Appareantly my question is a duplicate of this one.

Not exactly sure but pip install -e . seems to do what I want without too many extra stuff lying around. I'd prefer if my code wasn't linked from site-packages though.

      • 2
    • I have a script that creates a virtualenv, installs distribute and pip in it (...). You know you can do all 3 things with pip -E VENV_DIR pip as pip by default installs pip and distribute in the newly created environment?

In my package root issuing pip install -e . installs dependencies.

  • 19
Reply Report
    • That's some pretty serious side-effecting. -e installs in editable mode, which means the package gets linked from site packages instead of copied. I'd expect this approach to cause weird and subtle problems when you go and try to install the package for real, especially if you don't pip uninstall it first.
      • 1
    • Please note that it works only for setup.py based builds for now, there is no support for pyproject.toml yet.

If your dependencies are defined in the setup.py file, you can first dump them to an external file using:

python setup.py egg_info

This will list all your dependencies in YOUR_PROJECT.egg-info/requires.txt file. Then you can install them using pip:

pip install -r *.egg-info/requires.txt
  • 16
Reply Report

You should use the pip requirements file.

Essentially, place all your requirements, one in each line in a file and pass that to pip using the command

pip install -r requirements.txt

What more, if you have a standard environment, pip can actually dump such a file from existing installs using the command:

pip freeze

You can put the file thus generated directly into the pip requirements, and call the previous command from your deployment script.

Pretty cool, isnt it? :)

  • 7
Reply Report
    • the difference being where the 'dependencies' are specified - in the requirements.txt (where you would specify "myrepo==1.0.1" or whatever) OR in the setup.py of the package in myrepo that you want to install. if you've already got the repo in hand then only installing the dependencies might make sense.
    • @Tgr I don't think that is correct. I just used pip3 to install via a requirements file and several transitive dependencies were installed.
      • 1
    • The question is asking for a way to install the dependencies of the package being developed. Its dependencies will be declared in the package's setup.py file. It could even have conditional dependencies (like based on OS). I don't think requirements.txt can handle that, but even if it can, you'd have to do some extra work to load the requirements into setup.py from the file.
      • 1
    • Cool, but it doesn't answer my question. I'm not looking for a way to define dependencies. Reading questions entirely and carefully helps goes a long way in providing correct answers.
      • 1
    • Wait, You can put all your dependencies in a file and ask pip to install them all for you. Isn't that what you are looking for? If not, I didn't properly understand your question. Even now.

To install your project's dependencies (i.e. install_requires + extra_requires) you have to extract your dependencies using setuptools egg-info and then install the filtered list of the combined dependencies:

python setup.py egg_info
pip install `grep -v '^\[' *.egg-info/requires.txt`
  • 0
Reply Report

Trending Tags