Juicy
Juicy

Reputation: 12530

Setup in virtualenv: `pip install -e .` vs `python setup.py install`

I'm following a Flask tutorial that has me using virtualenv, and with it I built an app directory tree that looks like this:

app/
|__app/
|__app.egg-inf/
|__setup.py
|__venv/

Inside my venv the tutorial tells me to run pip install -e . which appears to be using my setup.py to install dependencies and my application.

Why does the tutorial have me running pip install -e .? Why not python setup.py install? What are the differences?

(FWIW, export FLASK_APP=app; flask run works fine after pip install -e . but doesn't work after a python setup.py install)

Upvotes: 14

Views: 7996

Answers (1)

Jonas Adler
Jonas Adler

Reputation: 10809

First, the commands you mention are not equivalent, specifically python setup.py install does not give you an editable installation. The pip <-> python setup.py equivalents are:

Editable   pip                    setup.py
yes        pip install -e .       python setup.py develop    
no         pip install .          python setup.py install    

With that said, using pip is in general recommended for a range of reasons:

  • Dependencies are automatically installed
  • There is an easy way to uninstall

In your case, I highly suspect that your package has a dependency which is automatically installed if you use pip, but not if you use python setup.py install.

Upvotes: 20

Related Questions