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?
Use the pip install -r requirements. txt command to install all of the Python modules and packages listed in your requirements. txt file.
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.
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
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
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.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With