python pip - install from local dir

后端 未结 2 1445
春和景丽
春和景丽 2020-12-13 23:34

I have to download a git python repo and install since the pypi version is not updated.

Normally I would do this:

pip install mypackage
pip install m         


        
2条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-14 00:07

    All you need to do is run

    pip install /opt/mypackage
    

    and pip will search /opt/mypackage for a setup.py, build a wheel, then install it.

    The problem with using the -e flag for pip install as suggested in the comments and this answer is that this requires that the original source directory stay in place for as long as you want to use the module. It's great if you're a developer working on the source, but if you're just trying to install a package, it's the wrong choice.

    Alternatively, you don't even need to download the repo from Github at all. pip supports installing directly from git repos using a variety of protocols including HTTP, HTTPS, and SSH, among others. See the docs I linked to for examples.

提交回复
热议问题