Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to install packages into specific conda environment? #23

Open
UncasRipley opened this issue Apr 2, 2018 · 2 comments
Open

How to install packages into specific conda environment? #23

UncasRipley opened this issue Apr 2, 2018 · 2 comments

Comments

@UncasRipley
Copy link

How do I use this module to install package to specific environment?

For example,
Given that I have Anaconda installed under /opt/anaconda2/,
and that I have manually created environment called 'myconda'

I want to write a task to install package pip into environment 'myconda'

Here is an example task:

  • name: Install pip via conda module
    conda:
    name: pip
    state: latest
    executable: /opt/anaconda2/bin/conda
    extra_args:
    - "-n myconda"

This does not work in my environment with ansible 2.4.3.0

@jiffyclub
Copy link
Member

Do you get an error, or does it end up installing into the default environment?

@ericpardee
Copy link

I feel the conda ansible module install should work like the conda create command and create the environment if it does not exist.

  • name: Create virtual environment rtp and install biopython
    conda: name=biopython state=latest extra_args="-n rtp" executable="{{ app_home }}/rtp/anaconda3/bin/conda"

Instead, conda ansible module errors:
TASK [rtp-python : Create virtual environment rtp and install biopython] *************************
fatal: [eric-rtp-python.preprod.com]: FAILED! => {"changed": false, "module_stderr": "Shared connection to eric-rtp-python.preprod.com closed.\r\n", "module_stdout": "Traceback (most recent call last):\r\n File "/tmp/ansible_XRIZTY/ansible_module_conda.py", line 373, in \r\n _main()\r\n File "/tmp/ansible_XRIZTY/ansible_module_conda.py", line 369, in _main\r\n conda, name, version, state, module.check_mode, command_runner, module.fail_json, module.exit_json)\r\n File "/tmp/ansible_XRIZTY/ansible_module_conda.py", line 94, in run_package_operation\r\n correct_version_installed = check_package_installed(command_runner, conda, name, version)\r\n File "/tmp/ansible_XRIZTY/ansible_module_conda.py", line 126, in check_package_installed\r\n command_runner, name, version, [conda, 'install', '--json', '--dry-run', get_install_target(name, version)])\r\n File "/tmp/ansible_XRIZTY/ansible_module_conda.py", line 239, in run_conda_package_command\r\n return command_runner(command)\r\n File "/tmp/ansible_XRIZTY/ansible_module_conda.py", line 366, in command_runner\r\n return run_conda_command(module, command)\r\n File "/tmp/ansible_XRIZTY/ansible_module_conda.py", line 333, in run_conda_command\r\n raise CondaCommandJsonDescribedError(command, output, stderr)\r\n__main.CondaCommandJsonDescribedError: Error running command: ['/home/app/rtp/anaconda3/bin/conda', 'install', '--name', 'rtp', '--json', '--dry-run', 'biopython']. stdout: {"exception_name": "EnvironmentLocationNotFound", "caused_by": "None", "exception_type": "<class 'conda.exceptions.EnvironmentLocationNotFound'>", "location": "/home/app/rtp/anaconda3/envs/rtp", "error": "EnvironmentLocationNotFound: Not a conda environment: /home/app/rtp/anaconda3/envs/rtp", "message": "Not a conda environment: /home/app/rtp/anaconda3/envs/rtp"}.\r\n", "msg": "MODULE FAILURE", "rc": 1}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants