So, I guess this is done in a really simple way, but I do not have experience with it, so I do not understand what is the issue. Let's say I have a conda environment example_env and a Singularity image example.simg.
I can run the image:
singularity run --nv /mnt/appl/singularity_images/pytorch-19.03-py3.simg
Once I am in the Singularity container, I can write conda activate example_env, and it works for me without any problem.
Now, I want to switch from the interactive section to a script. So, instead of using singularity run and entering the interactive shell, I have tried singularity exec: singularity exec example.simg bash scripts/train.sh, where train.sh contains only one (just for now, of course) command: conda activate example_env.
However, now it does not work, and gives me the following error: CommandNotFoundError: Your shell has not been properly configured to use 'conda activate'. To initialize your shell, run $ conda init <SHELL_NAME> If I try to follow the error message, and add the conda init command, it does not help.
What is wrong, and how can I run conda activate with singularity exec?
I don't think you run the echo commands as shown in this stackoverflow.
I think you should check out the following.
Activate conda environment on execution of Singularity container in Nextflow
Related
I installed miniconda on our CentOS cluster and it all went fine. Then I asked miniconda to create a python 3.8 environment, and it went fine. However, when I try to activate the environment, I get the following error:
CommandNotFoundError: Your shell has not been properly configured to use 'conda activate'.
To initialize your shell, run
$ conda init <SHELL_NAME>
I verified, and it's a bash environment. So I ran conda init bash and I got the following outputs:
no change /MyPath/miniconda3/condabin/conda
no change /MyPath/miniconda3/bin/conda
no change /MyPath/miniconda3/bin/conda-env
no change /MyPath/miniconda3/bin/activate
no change /MyPath/miniconda3/bin/deactivate
no change /MyPath/miniconda3/etc/profile.d/conda.sh
no change /MyPath/miniconda3/etc/fish/conf.d/conda.fish
no change /MyPath/miniconda3/shell/condabin/Conda.psm1
no change /MyPath/miniconda3/shell/condabin/conda-hook.ps1
no change /MyPath/miniconda3/lib/python3.9/site-packages/xontrib/conda.xsh
no change /MyPath/miniconda3/etc/profile.d/conda.csh
no change /home/users/me/.bashrc
No action taken.
So nothing happens. And when I try to activate the new environment, then I still get the first error.
Any idea how I can fix this?
[Solution] Thanks to the answer below, the issue was that despite testing that I was running/using a bash, I still have to run "bash" in the command line before activating model.
have you tried manually adding to ~/.bashrc?
add export PATH="/home/username/miniconda/bin:$PATH" in your bashrc file. make sure to replace /home/username/miniconda with your actual path now save the file, quit and reopen the terminal should work I guess.
In my Dockerfile, I create one Conda environment and install all packages I need. At the end of Dockerfile, I would like to start one service when container is created.
The original Dockerfile is not Conda environment, the commands look like:
EXPOSE 8868
CMD ["/bin/bash","-c","hub install deploy/hubserving/ocr_system/ && hub serving start -m ocr_system"]
I would like to modify the commands like so:
activate myenv
hua install and hub servering start
How do I activate the Conda environment in the container?
If you know where your conda is located (let's say /opt/miniconda3/condabin/conda), then you could directly use conda run. Something like:
CMD ['/opt/miniconda3/condabin/conda', 'run', '--no-capture-output',
'hub', 'install', 'deploy/hubserving/ocr_system/', '"&&"',
'hub', 'serving', 'start', '-m=ocr_system']
The argument delimiting might need some adjusting, but that's the spirit of it.If this is a non-base env, then you may also need a --name|-n argument to the conda run.
I am trying to create .sh and .cmd scripts that set up a conda environment. In the scripts, after creating the conda environment, I have additional commands to install some 'development mode' packages. However, the script exits after running the conda env create command (the environment is successfully created). Is there any way to ensure that the call to conda env create doesn't exit the script?
here is the code within the script:
# Clone repos to current directory
git clone https://github.com/int-brain-lab/ibllib.git --branch develop
git clone https://github.com/int-brain-lab/iblapps.git --branch develop
git clone https://github.com/int-brain-lab/analysis.git
git clone https://github.com/int-brain-lab/IBL-pipeline.git
# Create conda environment from the .yaml file and activate
conda env create -f iblenv.yaml python=3.8
source ~/anaconda3/etc/profile.d/conda.sh
conda activate iblenv
# Install repos in 'development mode'
conda-develop ./ibllib
conda-develop ./iblapps
conda-develop ./analysis
conda-develop ./IBL-pipeline
I believe issue is here:
source ~/anaconda3/etc/profile.d/conda.sh
if conda.sh contains exit command, it will stop executing of your shell script because source means that conda.sh will be executed in the current process.
You can try to add echo before and after "source" command to check that "conda env create" is not the latest command.
I've been trying all day to debug a code using Visual Studio Code without success. I have installed VSC on windows and I have installed bash (ubuntu) as well. I already put bash as a terminal default shell:
"terminal.integrated.shell.windows": "C:\\Windows\\System32\\bash.exe"
The thing is when I run the debug, it tries to activate the env with activate myenv-name and I couldn't find how to change this instruction to source activate myenv-name.
Do you know how I can do this? any help will be appreciated. Thanks!
It's been a while since I asked this question and I got the answer finally. :)
It is simple we just have to create .bashrc file in our user folder there we can write whatever commands we need to run each time we start a terminal in vscode.
Here the command to activate a conda env:
source activate myenv_name
In case of bash: conda: command not found and you don't have admin permissions to change the paths use this command before source act...:
export PATH=$"/c/Users/UserName/AnacondaPath/Scripts":$PATH
If I create a new Conda environment, for example conda create --name Test, how can I launch Jupyter or QtConsole using the Test environment?
Do I need to manually launch it from the command line rather than using the shortcut?
Do I need to manually launch it from the command line rather than using the shortcut
That would be the easiest way to do it.
One alternative is creating a custom .bat which activate the Test environment then launch the QtConsole application.