python pip - install from local dir

后端 未结 2 1444
春和景丽
春和景丽 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-13 23:58

    You were looking for help on installations with pip. You can find it with the following command:

    pip install --help
    

    Running pip install -e /path/to/package installs the package in a way, that you can edit the package, and when a new import call looks for it, it will import the edited package code. This can be very useful for package development.

    0 讨论(0)
  • 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.

    0 讨论(0)
提交回复
热议问题