After installing conda packages, login name disappears from Linux terminal - linux

After installing any conda package, login name disappears from Linux terminal. For reference please see screenshot.

Looks like you installed conda 22.9.0. Changes were made to the shell interface requiring a one-time re-initialization of conda:
conda init bash
After running the above command, you will need to restart your shell for the changes to take effect.
See: https://github.com/conda/conda/issues/11885

Related

Mac install python without developer tools

I am trying to install python 3.11 without the Mac developer tools, which will give me python3.9. But when I used the vscode to open a python file, the command line installer poped up and showed the following message 'the python3 command requires the command line developer tools ....'. But I can run the python3 command in the terminal successfully.
The annoying part is the pop up window. I found some suggestions about relink or rebuild the Xcode / command line tools. But in my case, there is no Xcode path. Please let me know if there is a way to configure the path correctly.
Thank you,
I checked the link of python3 in /usr/bin
I install the python directly from the http://python.org
Do you use Homebrew in your terminal?
You can try to run brew link --overwrite --dry-run python#3.11 in your terminal to see if you need to do an update for your env path. If you do need it, the terminal will give you suggestions to relink, ex. brew link --overwrite python#3.11 or rm '/usr/local/bin/2to3-3.11'
I also had an issue when installing python3.11 through Homebrew in my terminal, it said I must use xcode-select --install to install python3.11.
So later on, I followed this video step by step, and now it works. Whenever I check python3 --version, it returns Python 3.11.1. It also allows me to install another library that depends on python3.11.
Maybe it is worth checking the current version in your terminal and seeing if need to install again the package.

Creating environment in miniconda on Mac M1

I recently got a new Mac with M1 processor. From the terminal I installed miniconda through home-brew. Then, I tried to create a new conda environment as usual using conda create --name my_env. Then, I try to activate the environment using conda activate my_env, but 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>
Currently supported shells are:
- bash
- fish
- tcsh
- xonsh
- zsh
- powershell
See 'conda init --help' for more information and options.
IMPORTANT: You may need to close and restart your shell after running 'conda init'.
I obey of course, and I run conda init bash and close and restart my shell. However, when I then try to activate my environment I receive the above error again (and rerunning conda init bash does not fix the problem because it simply says 'no action taken'.
Questions:
Does anyone know why I still can't run conda activate?
Is it smart to even use miniconda for Python without Rosetta?
Many thanks
Mac changed the shell from Bash to Zsh a couple years ago. So, you need to do
conda init zsh

How to find out if conda is already available on a machine within a bash script?

I want to create a bash script to install a new virtual environment "ABC" in conda. But before I go ahead and run a command to create this env, I want to check if conda is already installed on the machine. If not installed, I want to install miniconda and then create the env "ABC". If conda is already installed then I would just go ahead and create the environment. (All this should happen within the same script)
I just want to know if it is possible to check the existence of conda within a bash script and then proceed with the rest of the installations?
'''
#!/bin/bash
<code_to_check_existence_of_conda_env_here ?>
//If it does not exist, I will run the below code
mkdir -p miniconda3
wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh -O
miniconda3/miniconda.sh
bash miniconda3/miniconda.sh -b -u -p ~/miniconda3
conda env update -f my_env.yml
'''
The main issue here is that Conda has multiple components. Which components are loaded depends on the how Conda is installed and what user the BASH script is executing under. I'll try describing the components and hopefully you can decide what is suitable to verify.
Conda Components
1: Conda Package
The first is a Python package conda, which is installed in the Anaconda/Miniconda/Miniforge base environment. If the base environment is activated, one could test
python -m conda
which will give something like
/path/to/python: No module named conda
if it isn't there. Otherwise, it outputs the conda entrypoint's documentation.
2: Conda Entrypoint
The entrypoint conda, which acts as a CLI, is located under the condabin directory of the Anaconda/Miniconda/Miniforge installation. When a user runs conda init, a managed section is added to their shell initialization file (.bashrc for Linux BASH), that includes code to add the condabin to PATH. This is most likely what OP wants to identify, however, running with the shebang /bin/bash will not load the .bashrc file. Instead, one should probably be using
#!/bin/bash -l
or
#!/usr/bin/env bash -l
Then the entrypoint can be located with
which conda
3: Conda Activate
Finally, Conda also includes some shell-only functions, which are defined in the aforementioned shell initialization code. This sets up a middleman shell function, also called conda (essentially an alias), which can be viewed with
type conda
This function serves to determine whether the conda (de)?activate commands are being requested, which are pure shell functions, or something that needs to be forwarded to the entrypoint.
Recommendation
Were I designing this, I would write an interactive script that checks for #2 (which conda) and if that comes up blank then prompt the user to either provide the PATH to the Conda entrypoint (maybe they installed it in a weird place or didn't run conda init) or install Miniforge.1
I also would not use the base environment to install stuff - that is a bad idea for an end-user, let alone a third-party - and instead create a new environment. I would prompt the user with a specific default environment name, but also provide an option for them to customize.
[1] Yes, Miniforge, not Miniconda. Commercial use of the Anaconda defaults channels now requires a paid license, so better to use the free Miniforge.
I'm not really good at bash scripting but I would execute a command:
pip3 freeze | grep conda
and based on the output (if exit status was an error or not) install it or directly create the environment.
run the command conda list on your machine, the output will of be different when its installed vs not installed, then run if statement on the output.
In bash, if we want to check if a software is installed or not, the following check is used.
if dpkg -l $SOFTWARE; then
<Do stuff>
ensureconda
This sounds like the intended problem that the experimental tool ensureconda was designed to solve. This, however, requires a Python installation with pip:
pip install ensureconda
Here are the command options:
$ ensureconda --help
Usage: ensureconda [OPTIONS]
Ensures that a conda/mamba is installed.
Options:
--mamba / --no-mamba search for mamba
--micromamba / --no-micromamba search for micromamba, install if not
present
--conda / --no-conda search for conda
--conda-exe / --no-conda-exe search for conda.exe / conda-standalone,
install if not present
--no-install don't install conda/mamba if no version can
be discovered
--min-conda-version VERSIONNUMBER
minimum version of conda to accept (defaults
to 4.8.2)
--min-mamba-version VERSIONNUMBER
minimum version of mamba/micromamba to
accept (defaults to 0.7.3)
--help Show this message and exit.
Type conda activate
or conda activate env_name
The first command will activate the base environment if it is already installed. The second command will do activate the user created environment if it is installed.

Group Install "GNOME Desktop"

Puppet Version: 3.8.7
I have been working on building some system monitoring boxes and have ran into an issue when it comes to installing group yum packages. The normal course of installing packages of course isn't working but I figured that I would at least be able to work around this by including an exec to run the install as a command (like below):
exec { "GNOME Desktop":
command => "/usr/bin/yum -y groups install 'GNOME Desktop'",
timeout => 600,
}
There is an available module on the puppet forge that seems to do what I want but it's not compatible with our version of puppet and we are not in a place to upgrade at this time.
I also tried the setup that was listed in the below server fault question but it also did not work for me:
https://serverfault.com/questions/127460/how-do-i-install-a-yum-package-group-with-puppet
I have also manually been able to run the following command but when I exec it as a puppet command, it fails:
/usr/bin/yum -y groups install "GNOME Desktop"
Why is this? I assumed that puppet is just issuing the command in the exact same way the terminal would?
Changing the time out (or removing it) had zero effect, the issue is with the version of puppet and the ability to install group packages. I ended up installing the desktop environment in my kickstart file and ran puppet for everything else.

How to fix conda update conda permission error

~$ conda update conda
Solving environment: done
## Package Plan ##
environment location: /home/david/anaconda3
added / updated specs:
- conda
The following packages will be UPDATED:
conda: 4.4.10-py36_0 --> 4.4.11-py36_0
Proceed ([y]/n)? y
Preparing transaction: done
Verifying transaction: done
Executing transaction: failed
ERROR conda.core.link:_execute(481): An error occurred while uninstalling package 'defaults::conda-4.4.10-py36_0'.
PermissionError(13, 'Permission denied')
Attempting to roll back.
Rolling back transaction: done
PermissionError(13, 'Permission denied')
I was trying to update conda on virtualbox ubuntu 16.04 and this permission error came up. I tried sudo conda update conda but it returns sudo: conda: command not found. I'm not sure where to go from here.
I got the same error and solved it by this:
sudo env "PATH=$PATH" conda update conda
All conda commands must be run without super user privileges. That's why sudo conda command doesn't work.
You may have run conda installation bush file with super user privileges while installing. The user (david) running conda doesn't have write permissions to paths(/home/david/anaconda3) it needs to modify in the environment, then conda can't do anything. To solve this problem you need to change permissions to paths (/home/david/anaconda3).
To change permissions to paths (/home/user/anaconda3) using:
sudo chown -R user /home/user/anaconda3
I solved this problem by right clicking on Anaconda Prompt, selecting "Run As Administrator", and typing the command that I want to execute.
This problem arise if at installation time, we select an option install for all user anaconda. It can be solved as I mentioned above - run it as Administrator and type the conda commands for install, updating the packages.
It's Permission denied, So just sudo chown -R frazier:frazier /home/frazier/anaconda3
PS: change 'frazier' to your user name.
conda install numpy
{
Executing transaction: failed
ERROR conda.core.link:_execute(502): An error occurred while uninstalling package 'defaults::conda-4.5.4-py27_0'.
OSError(13, 'Permission denied')
Attempting to roll back.
Rolling back transaction: done
OSError(13, 'Permission denied')}
solution:
to change the permission to conda, use the command :
sudo chown -R nikhil /home/nikhil/miniconda
chown command changes the permission of miniconda to use sudo.
now you have the permisssion to access sudo..
now use:
conda update conda
now
Executing transaction: Done
You have installed Anaconda with sudo or root user. You need to install it with normal ubuntu/<Your username> user.
Remove or take backup of the already installed Anaconda (/home/<user>/anaconda3).
With normal mode install anaconda ( bash conda_installer_script ) .
Check .bashrc for this line and validate it.
export PATH="/home/<username>/anaconda3/bin:$PATH"
If not add it with proper anaconda path .
Reload .bashrc file and check conda is working by conda list command.
Now you can do conda update conda
I too had this error and resolved it by doing the following things - a little strange but worth a try.
1. Run as administrator
2. Run the code below to specifically update package in an environment -myenv
$conda install --name myenv numpy
3. For me the environment was running hence it was not updating, once I closed my running workbooks, and ran Point 1 and 2 .. it worked :)
if you have this error message during package installation in anaconda then follow the given step:
open the anaconda prompt by right click.
select the run as administrator.
type the command for install package.eg conda install numpy
Run Anaconda Prompt using "Run as Administrator" option and then
run the command -> conda update conda
Then go back to starting Anaconda Prompt as usual and I believe everything should be fine.
Also, don't forget to add Anaconda3 path to Environment variables.

Resources