39

When I want to install modules to Anaconda, I run conda install. However, now I have a .tar.gz file and want to install this. How to do?

Holt
  • 36,600
  • 7
  • 92
  • 139

5 Answers5

53

There are several ways to achieve this, I'm describing one here, which should be relatively straight forward, even if your default python variable is not anaconda's.

  1. Check what is your desired anaconda environment (if you're not sure what does this mean, it probably means that you are using root, the default environment)
  2. Run: conda info --envs to see the path where your environment is installed
  3. Go to that path, and find the absolute path to python.exe, for example: "C:\Program Files\Anaconda3\python.exe"
  4. Now, run the following command:

<absolute path to python.exe> -m pip install <path to tar.gz>

for example:

C:\Program Files\Anaconda3\python.exe -m pip install c:\mymodule\great.tar.gz

Note that <path to tar.gz> can be relative, absolute and even an online link.

Ori
  • 1,680
  • 21
  • 24
19

It depends on where your archive comes from:

  • If you got it from pypi, you need to install it using pip:
pip install package.tar.gz
# Or:
python -m pip install package.tar.gz
  • If you got it from conda-forge, you need to use conda:
conda install package.tar.gz

If you have multiple python installations, you may need to specify absolute path to the python/conda executable.

Note that the archive files on pypi and conda-forge are usually very different:

  • pypi archives contain source files, so you may need to build the package in order to install it, which may requires external dependencies;
  • conda-forge are architecture-specific and contains pre-built package, which are much less likely to require external dependencies.

If you already have a working Anaconda distribution, I would encourage you to get archives from conda-forge instead of pypi.

Holt
  • 36,600
  • 7
  • 92
  • 139
3

Here is how to do :

Q:\anaconda3\Scripts>conda install q:\quandl-3.4.4-py37_0.tar.bz2

Downloading and Extracting Packages

########################################################################################### 
#################################################################### | 100%
Preparing transaction: done
Verifying transaction: done
Executing transaction: done

Q:\anaconda3\Scripts>
ETO
  • 6,970
  • 1
  • 20
  • 37
1

If you are using Anaconda and downloaded the package from Anaconda Cloud, then you can place your "package.tar.bz2" files in the path shown in Anaconda prompt (Eg. C:\Users) and type in the following command in Anaconda Prompt

conda install package.tar.bz2

I believe it will work for .tar.gz files too.

1

Just a PSA please don't use conda install <pkg.tar> when updating python from a tar.bz. This has the potential to break Anaconda.

SteveZ
  • 21
  • 3
  • Comment, I lack credit to post it as such. I only added it as an answer to prevent others from following the general comment at the top of the thread. I'l gladly remove it if you know a way for me / someone else to add it as a comment. – SteveZ Feb 16 '21 at 17:01