33

To install to my own directory I can use

pip install --user package

Alternatively I can use

conda install package

How do I ask conda to install to my home directory since conda does not take a --user flag?

Installing pip packages to $HOME folder

wjandrea
  • 28,235
  • 9
  • 60
  • 81
Sam Weisenthal
  • 2,791
  • 9
  • 28
  • 66

8 Answers8

15

I don't think it's possible. Use virtual environments (conda create).

phd
  • 82,685
  • 13
  • 120
  • 165
9

See -p option here:

 -p PATH, --prefix PATH
              Full path to environment prefix.

So to install to, say, local under your home directory, do:

conda install -p $HOME/local packagename

Note, however, this is not a "clean" install as it adds a bunch of conda-related files.

erobertc
  • 644
  • 1
  • 9
  • 20
Andrey Portnoy
  • 1,430
  • 15
  • 24
9

To install conda packages on your own directory you can follow these steps:

  1. Create a blank environment

    conda create -y -n my-conda-env
    

    Replace the name my-conda-env with any name you want to give the environment.

  2. Activate the environment

    source activate my-conda-env
    

    Don't forget to replace my-conda-env with the name you gave the conda environment from the previous step

  3. Install your package

    conda install -c bioconda epa-ng
    

And that's it, the package should be installed on your own directory

wjandrea
  • 28,235
  • 9
  • 60
  • 81
jcoder8
  • 163
  • 1
  • 9
0

Simply:

sudo conda install -c conda-forge package

Or:

sudo chmod -R 777 ./
conda install -c conda-forge package
razimbres
  • 4,715
  • 5
  • 23
  • 50
0

I don't know of an exact match for the --user flag, but a reasonable analogue is to use a virtual environment.

What I do when I have to install to a shared CentOS server where I don't have admin access:

First I run

conda env list

will list all conda virtual environments and display the path to each. Once you have the environment created and can see it in the conda env list, copy the path to the environment.

If you need to create one, you can do that with conda create or by running anaconda-navigator and using the GUI.

Activate your environment (if not active) with

conda activate [environment_name]

or

activate [environment_name]

depending on your system (most linux systems use the first, Windows and CentOS use the latter).

Now you can use

conda install -p [environment_path] [package_name]

and you are off to the races.

This is really a work around; it's not the best but it does install the package to the selected virtual environment.

KRBundy
  • 411
  • 4
  • 4
0

The current Anaconda Install Individual Edition, when run in a linux local account, installs in a local directory. So all the subsequent installs should install there, too.

arivero
  • 777
  • 1
  • 9
  • 30
0

Besides the method mentioned by Andrey Portnoy, you can also define the default environment path in the .condarc file.

You can check the environment directories conda currently uses by checking the key envs directories with

conda info

When creating a new named environment, conda will place the environment in the first writable environment in the list.

So, to change my default environment path, I have added the following lines to my .condarc file in my $HOME directory.

envs_dirs:
  - /Users/myusername/.conda/envs
  - /usr/local/Caskroom/miniconda/base/envs
p13rr0m
  • 1,107
  • 9
  • 21
-7

According to the documentation:

--use-local

MR.Mohebian
  • 162
  • 1
  • 7
  • 8
    Using this, I still get `The current user does not have write permissions to the target environment.` – Blade Jul 08 '19 at 23:43
  • 18
    This answer is not correct. The documentation says '--use-local' is "Identical to '-c local'." which means it is using a local channel for the package source, not installing for the local user. – D. Ror. Aug 30 '19 at 18:23