Can I install packages from specific channels when using PIP as it's possible in Anaconda?
Solution 1
pip
supports specifying additional repositories to look for packages; these behave similarly to channels in conda<4
. Example:
$ pip install somepkg --extra-index-url http://myindex.org
Multiple additional indexes can be specified in pip.conf
:
[global]
extra-index-url=
http://myindex.org
http://other-index.org
http://third-index.org
When an index is provided via extra-index-url
, pip
will always search the default index at https://pypi.org, then the extra index and install the first matching package. Overriding http://pypi.org is also possible, via
$ pip install --index-url http://myindex.org
hosting a local index
It's actually pretty easy to host a local index if you need one. Although there are a lot of third-party PyPI servers available (to name a few: devpi
, wheelhouse
or pypiserver
), you need nothing besides a Python installation to fire up one yourself. Create a directory with subdirs named same as packages and containing the installation files:
repo
└── MyPackage
└── MyPackage.tar.gz
Navigate to the directory and run the stdlib's server:
$ cd repo/
$ python -m SimpleHTTPServer 9000
Now you can install the packages from your local repository:
$ pip install MyPackage --extra-index-url = http://127.0.0.1:9000/
Solution 2
If I am not mistaken, I believe that pip
doesn't have "channels" in the same way that Anaconda does. Essentially, pip
assumes that for simple online installs (e.g. pip install package_name
), it will be pulling from PyPI.
That said, regardless, it certainly is possible to pull from other sources (both local and remote) — see the official Python installing packages guide for some examples. Supported sources can include version control systems (VCSs), alternate Indexes (i.e. not PyPI), local src tree, and local archives/wheels.
More VCS support documentation for Git, Mercurial, Subversion and Bazaar can be found here.
Related videos on Youtube
Comments
-
Daniel Möller over 1 year
In Anaconda, there is the option of adding "channels" to the configuration files.
Every package installed with
conda install ...
will first look for packages in these channels (such as theintel
channel, for instance).Is there a way to make PIP also install from specific channels?
-
Daniel Möller almost 6 yearsThis is very very probably the answer, but how could I find the url for the channels used by anaconda? For instance, there is the
intel
channel (and only that, no address, no easy info on the internet) -
hoefling almost 6 yearsI'm not much into
conda
, but AFAIRconda info
should at least print all the URLs of channels used, but no name mapping.