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

女生的网名这么多〃 提交于 2019-12-04 19:21:14

问题


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)


回答1:


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.



来源:https://stackoverflow.com/questions/45426794/setup-in-virtualenv-pip-install-e-vs-python-setup-py-install

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!