Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Installing Packages from Multiple Servers from One or More Requirements File

Tags:

python

pip

I have tried the following two approaches without success.

The first with Cascading Requirements Files.

# requirements.txt
-r requirements/req2.txt
-r requirements/req3.txt
# requirements/req2.txt
Django==1.7.7
# requirements/req3.txt
-i https://testpypi.python.org/pypi
foo-bar==0.4

pip install -r requirements.txt results in pip not finding Django.

The second attempt was to include both requirements in a single file:

-i https://pypi.python.org/pypi/
Django==1.7.7
-i https://testpypi.python.org/pypi
foo-bar==0.4

pip install -r requirements.txt results in the same error, pip not finding Django.

How can I use pip to install packages from different servers/index-urls?

like image 785
robbmj Avatar asked Mar 26 '15 22:03

robbmj


People also ask

How do I install all packages in requirements txt?

Use the pip install -r requirements. txt command to install all of the Python modules and packages listed in your requirements. txt file.

Can you install multiple packages with pip?

To pip install more than one Python package, the packages can be listed in line with the same pip install command as long as they are separated with spaces. Here we are installing both scikit-learn and the statsmodel package in one line of code. You can also upgrade multiple packages in one line of code.

How do I install multiple packages on a Linux system?

To install multiple packages simply list one after the other: sudo apt-get install package-name1 package-name2 package-name3 To force apt-get install to answer yes to any are you sure you want to install this package? questions which may arise add a -y to the end sudo apt-get install package1 package2 package3 -y

What are the requirements for installing packages?

Requirements for Installing Packages Ensure you can run Python from the command line Ensure you can run pip from the command line Ensure pip, setuptools, and wheel are up to date Optionally, create a virtual environment Creating Virtual Environments Use pip for Installing

How many software can One installer install at a time?

One installer can install only one software at a time. You can always install 2 or more software from source, binaries in parallel. Most Linux distributions have a common package manager, or "installer" for most software supported by that distribution.

Can I install 2 programs at the same time in Linux?

You can always install 2 or more software from source, binaries in parallel. Most Linux distributions have a common package manager, or "installer" for most software supported by that distribution. Unlike windows, in which each software comes with its own installer and hence they run in parallel.


1 Answers

The solution in either case is to add --extra-index-url <url> at the beginning of the requirements.txt file.

Example:

# requirements.txt
--extra-index-url https://testpypi.python.org/pypi
Django==1.7.7
django-stackexchange-feed==0.4

Or to use Cascading Requirements Files:

# requirements.txt
--extra-index-url https://testpypi.python.org/pypi
-r requirements/req2.txt
-r requirements/req3.txt
# requirements/req2.txt
Django==1.7.7
# requirements/req3.txt
foo-bar==0.4

pip install -r requirements.txt will now work.

like image 56
robbmj Avatar answered Oct 15 '22 23:10

robbmj