I am not interested in installing my package itself but I am interested installing all the dependencies used by my package. Is there a way to do this using setup.py
? It seems setup.py
installs my package and all dependencies.
Asked
Active
Viewed 7,234 times
26
-
1So, you have package `abc` which is dependent on `xyz`, you want to install `xyz` but not `abc` am i right ? – Nilesh Jun 12 '15 at 07:04
-
https://pythonhosted.org/setuptools/setuptools.html#easy-install-find-and-install-packages – sobolevn Jun 12 '15 at 07:08
-
1If the package you downloaded has a requirements file, it's as easy as `pip install -r requirements.txt`. – Jun 12 '15 at 07:24
3 Answers
14
Use the -e flag on pip install
pip install -e .

Nicolas Appriou
- 2,208
- 19
- 32
-
2I'm confused by this - `-e` is for "editable mode", which will do things like symlink the working directories of dependencies. In this case OP wants to install everything "for real", just not the one package under development. Does this handle the use case well? – Ken Williams Sep 03 '20 at 22:31
-
@KenWilliams editable mode will install everything "for real", *except* for the very package you're working on (this will be "symlinked", as you mentioned). You might not want this link to remain though -- which is what your trick with as subsequent `pip uninstall` handles. – karlicoss Sep 13 '20 at 15:06
-
this is obviously not the right answer! Why is this accepted? This will do much more than "only install dependencies". – Charlie Parker Aug 16 '22 at 15:50
12
The only way I've found to reliably do this in a straightforward manner is this:
pip install . && pip uninstall `python setup.py --name`

Ken Williams
- 22,756
- 10
- 85
- 147
-
1Thanks, great answer. One minor suggestion: `pip uninstall --yes`, so it doesn't prompt you (e.g. in a Dockerfile) – karlicoss Sep 13 '20 at 15:01
-
This is great answer! One minor comment is that it does not work for python3, however it is easy to adapt. – Qi Luo Jan 07 '21 at 22:23
-
-
In an environment with both python2 and python3, I could use ``pip3 install . && pip3 uninstall `python3 setup.py --name` `` – Qi Luo Jan 08 '21 at 21:25
-
@QiLuo Yeah, that's just because pip and python are apparently called `pip3` and `python3` in your environment. In mine, they're simply called `pip` and `python`. – Ken Williams Jan 08 '21 at 23:34
1
if you wan to do it from setup.py do:
python setup.py egg_info
pip install -r *.egg-info/requires.txt
rm -rf *.egg-info/
all of this ran from the project folder usually for me it's the root of my github where setup.py is.

Charlie Parker
- 5,884
- 57
- 198
- 323