193

Can I install/upgrade packages from GitHub using conda?

For example, with pip I can do:

pip install git+git://github.com/scrappy/scrappy@master

to install scrappy directly from the master branch in GitHub. Can I do something equivalent with conda?

If this is not possible, would it make any sense to install pip with conda and manage such local installations with pip?

4 Answers 4

166

The answers are outdated. You simply have to conda install pip and git. Then you can use pip normally:

  1. Activate your conda environment source activate myenv

  2. conda install git pip

  3. pip install git+git://github.com/scrappy/scrappy@master

1
  • 12
    Much of is already in the OP (using pip install). The question is asking how to do it using conda directly, which the top answer provides. Commented Jan 18, 2020 at 14:49
137

There's better support for this now through conda-env. You can, for example, now do:

name: sample_env
channels:
dependencies:
   - requests
   - bokeh>=0.10.0
   - pip:
     - "--editable=git+https://github.com/pythonforfacebook/facebook-sdk.git@8c0d34291aaafec00e02eaa71cc2a242790a0fcc#egg=facebook_sdk-master"

It's still calling pip under the covers, but you can now unify your conda and pip package specifications in a single environment.yml file.

If you wanted to update your root environment with this file, you would need to save this to a file (for example, environment.yml), then run the command: conda env update -f environment.yml.

It's more likely that you would want to create a new environment:

conda env create -f environment.yml (changed as supposed in the comments)

4
  • There is some documentation here, but it doesn't explain the pip part (just gives an example) but it's pretty self-explanatory. You can also export an existing conda env to yaml (including pip-installs).
    – drevicko
    Commented Feb 2, 2018 at 15:28
  • In case you need to install from a subdirectory: stackoverflow.com/questions/13566200/… e.g. - "--editable=git+github.com/poleguy/…"
    – poleguy
    Commented Oct 5, 2021 at 7:13
  • Using --editable didn't work, said not found, but removing it worked great. Thanks
    – Sos
    Commented Aug 31, 2022 at 15:02
  • I wish there was a way that wouldn't use pip and wouldn't require using a yaml file. it feels like a basic usecase. Commented Aug 9 at 20:53
31

conda doesn't support this directly because it installs from binaries, whereas git install would be from source. conda build does support recipes that are built from git. On the other hand, if all you want to do is keep up-to-date with the latest and greatest of a package, using pip inside of Anaconda is just fine, or alternately, use setup.py develop against a git clone.

1
  • 3
    What if your package has a release binary associated with it?
    – mr148
    Commented Jan 7, 2020 at 17:33
29

I found a reference to this in condas issues. The following should now work.

name: sample_env
channels:
dependencies:
   - requests
   - bokeh>=0.10.0
   - pip
   - pip:
     - git+https://github.com/pythonforfacebook/facebook-sdk.git
1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.