Reputation: 2395
What is the conda version of this?
pip install -r requirements.txt --target ./lib
I've found these commands:
while read requirement; do
conda install --yes $requirement
done < requirements.txt
But it doesn't tell how to specify --target ./lib
Upvotes: 236
Views: 338183
Reputation: 4835
would this work?
cat requirements.txt | while read x; do
conda install "$x" -p ./lib
done
or
conda install --file requirements.txt -p ./lib
Upvotes: 2
Reputation: 6782
To create an environment named py37
with python 3.7, using the channel conda-forge and a list of packages:
conda create -y --name py37 python=3.7
conda install --force-reinstall -y -q --name py37 -c conda-forge --file requirements.txt
conda activate py37
...
conda deactivate
Flags explained:
-y
: Yes, do not ask for confirmation.--file
: Take the next argument as a filename.--force-reinstall
: Install the package even if it already exists.-q
: Quiet, do not display progress bar.-c
: Channels, additional channels to search for packages. These are URLs searched in the orderAlternatively you can create an environment.yml file instead of requirements.txt:
name: py37
channels:
- conda-forge
dependencies:
- python=3.7
- numpy=1.9.*
- pandas
Use these commands to create and activate the conda environment based on the specifications in the Yaml file:
conda env create --file environment.yml
conda activate py37
Use this command to list the environments you have:
conda info --envs
Use this command to remove the environment:
conda env remove --name py37
New! The ansible-role dockpack.base_conda can manage conda environments on Linux, Mac and Windows, and can be used to create a docker image with custom conda environments.
Upvotes: 110
Reputation: 902
You can easily run the following command to install all packages in requirment.txt with an additional channel to search for packages:
conda install -c conda-forge --file requirements.txt
Upvotes: 2
Reputation: 484
You can always try this:
/home/user/anaconda3/bin/pip install -r requirements.txt
This simply uses the pip installed in the conda environment. If pip is not preinstalled in your environment you can always run the following command
conda install pip
Upvotes: 23
Reputation: 1063
A quick search on the conda official docs will help you to find what each flag does.
So far:
-y
: Do not ask for confirmation.-f
: I think it should be --file
, so it read package versions from the given file.-q
: Do not display progress bar.-c
: Additional channel to search for packages. These are URLs searched in the orderUpvotes: 5
Reputation: 94407
You can run conda install --file requirements.txt
instead of the loop, but there is no target directory in conda install. conda install
installs a list of packages into a specified conda environment.
Upvotes: 309