Modifying .name files when uninstalling anaconda - anaconda

I wanted anaconda to be completely uninstalled from my computer, then possibly reinstall it.
I did what is proposed here except that the last two lines on .bash_profile do not look like the ones I wish to remove.
I expected it to be clear what I wanted to delete, but it is not (for me at least).
Instead the .bash_profile looks like this:
# Setting PATH for Python 3.7
# The original version is saved in .bash_profile.pysave
PATH="/Library/Frameworks/Python.framework/Versions/3.7/bin:${PATH}"
export PATH
# added by Anaconda3 2019.10 installer
# >>> conda init >>>
# !! Contents within this block are managed by 'conda init' !!
__conda_setup="$(CONDA_REPORT_ERRORS=false '/Users/Tinius/opt/anaconda3/bin/conda' shell.bash hook 2> /dev/null)"
if [ $? -eq 0 ]; then
\eval "$__conda_setup"
else
if [ -f "/Users/Tinius/opt/anaconda3/etc/profile.d/conda.sh" ]; then
. "/Users/Tinius/opt/anaconda3/etc/profile.d/conda.sh"
CONDA_CHANGEPS1=false conda activate base
else
\export PATH="/Users/Tinius/opt/anaconda3/bin:$PATH"
fi
fi
unset __conda_setup
# <<< conda init <<<
eval "$(pyenv init -)"
Should I remove anything from here? For instance, what is inside the inner-else statement as this is the \export PATH="/Users/Tinius/opt/anaconda3/bin:$PATH" part talked about in the link above? If so, do I remove the entire else statement?
A second question:
Are there any other .name files I need to delete or modify to succesfully uninstall anaconda?
I'm sorry if this is completely noobish, but I have been rather lost with installing and uninstalling stuff on the Macbook pro mid 2014. I updated from Mojave to Big Sur today.
Thank you
Edit
Picture of files in /Users/myuser:
Files and folders screenshot

Related

PYTHONPATH environment variable not saving on macOS

Running echo $PYTHONPATH returns a blank line:
freddy#dave ~ % echo $PYTHONPATH
freddy#dave ~ %
echo $PATH returns properly
freddy#dave ~ % echo $PATH
/opt/homebrew/bin:/opt/homebrew/sbin: ...
.bash_profile for user freddy:
# Fig pre block. Keep at the top of this file.
export PATH="${PATH}:${HOME}/.local/bin"
eval "$(fig init bash pre)"
# Use Python 3.10, not homebrew
export PYTHONPATH="/Library/Frameworks/Python.framework/Versions/3.10/bin/python3.10"
export PATH="/opt/homebrew/bin:${PATH}"
source ~/.bash_profile
# Fig post block. Keep at the bottom of this file.
eval "$(fig init bash post)"%
Why does echo $PYTHONPATH return nothing? And how do I assign it to my Python3.10 path?
I've tried restarting, this does not help
I've run source ~/.bash_profile (this just closes the terminal after execution though?)
A test variable: export TEST="TEST" also echos a blank line
As the comment suggests, I'm trying to use Python3.10 instead of my Homebrew installation, which is for some system packages
I am using zsh, not bash.
I moved PYTHONPATH to .zshrc and it saves as an environment variable now.
However, I have opted for the pyenv setup. And have added the following to my .zshrc file:
eval "$(pyenv init --path)"
https://stackoverflow.com/a/69378384/14141223

How do I update the PATH in bash_profile on OSX

I'm trying to install flutter on my Mac, in order to do so I need to add a path to the .bash_profile. But when I run the command vim .bash_profile in the terminal ,I'm met with the following message.
# The original version is saved in .bash_profile.pysave
PATH="/Library/Frameworks/Python.framework/Versions/3.7/bin:${PATH}"
export PATH
export M2_HOME=/Applications/apache-maven-3.6.3
export PATH=$PATH:$M2_HOME/bin# added by Anaconda3 2019.10 installer
# >>> conda init >>>
# !! Contents within this block are managed by 'conda init' !!
__conda_setup="$(CONDA_REPORT_ERRORS=false '/Users/sofie-amaliepetersen/opt/anaconda3/bin/conda' shell.bash hook 2> /dev/null)"
if [ $? -eq 0 ]; then
\eval "$__conda_setup"
else
if [ -f "/Users/sofie-amaliepetersen/opt/anaconda3/etc/profile.d/conda.sh" ]; then
. "/Users/sofie-amaliepetersen/opt/anaconda3/etc/profile.d/conda.sh"
CONDA_CHANGEPS1=false conda activate base
else
\export PATH="/Users/sofie-amaliepetersen/opt/anaconda3/bin:$PATH"
fi
fi
unset __conda_setup
# <<< conda init <<<
This is my first time adding a PATH, I've tried looking at setting path in terminal
But I'm not sure how it applies to my problem.
Any suggestions would be appreciated. Thanks
Something important to note, is that if you're using Catalina (Or any of the newer forms os osx) your computer won't be using the bash shell by default (Although you'll still be able to update your bash_profile, it won't work, as the computer doesn't care). You'll need to update your zshrc instead of the bash profile. (just typing zsh in your terminal should be able to switch between them, showing you a % instead of a $)
The same process as with the bash profile can be used, and the same line too. Also if you WANT the computer to use the bash profile instead you can force it, but there's no realistic functionality changes between the two in 99% of applications.
Anywhere in your .bash_profile, add this line
export PATH=$PATH:/your/new/path/to/add
This simply add /your/new/path/to/add to your existing $PATH

Using Anaconda with zsh on Catalina

The Anaconda installer added this script originally to my .bashrc or .bash_profile so I copied it over to .zshrc when I switched to zsh. I recently read I didn't need to/shouldn't have copied it over since it was meant for .bash_profile, but now that macOS is moving to use zsh anyway I'd like to know what I should do. Obviously I need to tell zsh where Anaconda is but do I need that script or can I just export the Anaconda path like export PATH=/Users/ty604/anaconda3/bin:$PATH?
Script added by Anaconda installer.
export PATH=/Users/ty604/anaconda3/bin:$PATH
# added by Anaconda3 2019.03 installer
# >>> conda init >>>
# !! Contents within this block are managed by 'conda init' !!
__conda_setup="$(CONDA_REPORT_ERRORS=false '/Users/ty604/anaconda3/bin/conda' shell.bash hook 2> /dev/null)"
if [ $? -eq 0 ]; then
\eval "$__conda_setup"
else
if [ -f "/Users/ty604/anaconda3/etc/profile.d/conda.sh" ]; then
. "/Users/ty604/anaconda3/etc/profile.d/conda.sh"
CONDA_CHANGEPS1=false conda activate base
else
\export PATH="/Users/ty604/anaconda3/bin:$PATH"
fi
fi
unset __conda_setup
# <<< conda init <<<
I also have many duplicate paths in $PATH because of duplicate export commands in various shell files.
$ echo $PATH
/Users/ty604/anaconda3/bin:/Users/ty604/anaconda3/condabin:/Users/ty604/anaconda3/bin:/Users/ty604/.cargo/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Applications/VMware Fusion.app/Contents/Public:/usr/local/share/dotnet:/Users/ty604/flutter/bin
Files in my system
.bash_history, .bash_profile, .bashrc, .profile, .zprofile, .zsh_history, .zshrc, .zshrc.pre-oh-my-zsh
Folders in my system
.bash_sessions, .oh-my-zsh, .zsh
macOS will be using zsh moving forward and we can set zsh as the default shell in Catalina which I have done. With Catalina is it ok if I remove all traces of bash and oh-my-zsh since zsh is now the default shell? Also I am using Hyper Terminal which means I do not need oh-my-zsh any longer right?
If you are using zsh as your shell (which is up to you, since Catalina still provides bash as well), and need some settings for it, they should go into .zshrc, respectivels .zprofile. Of course you don't blindly copy everything from .bashrc over, because you need to be sure that the code is valid under Zsh too. However, the code snippet you posted, looks safe for me, i.e. it should work under both bash and zsh.
In this case, I suggest (for easier maintenance) to put initialization code common to bash and zsh into a separate file, say ~/.commonrc, and source this file in .zshrc and .bashrc. Note also that .zshrc is only read if this is an interactive shell. See the section STARTUP/SHUTDOWN FILES in the zshall man-page.
Found out via an Anaconda dev post that she was using
conda_setup="$(CONDA_REPORT_ERRORS=false '/Users/user_name/anaconda3/bin/conda' shell.zsh hook 2> /dev/null)"
Couldn't find shell.zsh hook anywhere else so hopefully this will help someone else.
I am proceeding to move all bash files outside of my system since the default macOS zsh shell is now zsh.

How do I add a path in my bash profile for anaconda installed on another drive?

I have two drives installed in my computer, one running the OS and one the home directory. I have used anaconda and python on the home directory, but since the drive running the OS is an SSD, I would like to run anaconda and all python programming on this drive.
I have uninstalled anaconda from the old drive and deleted the path variables in the bash profile.
After reinstalling anaconda now on the new drive I've tried to add the path in my bash profile to the anaconda3/bin file, however I get the following errors:
-bash: /Volumes/HDD/.bash_profile: line 4: unexpected EOF while looking for matching `''
-bash: /Volumes/HDD/.bash_profile: line 26: syntax error: unexpected end of file
I have attached my bash profile to the question. I have deleted a fair bit of stuff when I uninstalled anaconda from the previous drive, but it was only things referring to itself - could it be that I deleted some other path variable?
I might have some fundamental problem with this split that I don't know about - a question I have also been searching was how I can change terminal to also 'work' on the mother directory /Volumes/.
My directories:
/Volumes/SSD/anaconda3 # containing anaconda
/Volumes/SSHD # containing the home directory, 'running' terminal
I have tried to write
export PATH="/Volumes/SSD/anaconda3/bin:$PATH"
into the bash profile, but the same errors came up, so I copied the standard conda init from another question but still no luck.
# >>> conda init >>>
# !! Contents within this block are managed by 'conda init' !!
__conda_setup="$(CONDA_REPORT_ERRORS=false ‘/Volumes/SSD/anaconda3/bin/conda' shell.bash hook 2> /dev/null)"
if [ $? -eq 0 ]; then
\eval "$__conda_setup"
else
if [ -f "/Volumes/SSD/anaconda3/etc/profile.d/conda.sh ]; then
. "/Volumes/SSD/anaconda3/etc/profile.d/conda.sh"
CONDA_CHANGEPS1=false conda activate base
else
\export PATH="/Volumes/SSD/anaconda3/bin:$PATH"
fi
fi
unset __conda_setup
# <<< conda init <<<```
export PS1="\[\033[36m\]\u\[\033[m\]#\[\033[32m\]\h:\[\033[33;1m\]\w\[\033[m\]\$ "
export CLICOLOR=1
export LSCOLORS=AhFxBxDxCxegedabagacad
BASH is complaining that it found a start of a quote, but couldn't find the end.
Line 3 of your script:
__conda_setup="$(CONDA_REPORT_ERRORS=false ‘/Volumes/SSD/anaconda3/bin/conda' shell.bash hook 2> /dev/null)"
Should be:
__conda_setup="$(CONDA_REPORT_ERRORS=false '/Volumes/SSD/anaconda3/bin/conda' shell.bash hook 2> /dev/null)"
Note the subtle difference between the original character: ‘ and the replaced character ' after false and before /Volumes
You also have an unterminated quote on line 7 after "conda.sh". Should be:
if [ -f "/Volumes/SSD/anaconda3/etc/profile.d/conda.sh" ]; then

How do I prevent Conda from activating the base environment by default?

I recently installed anaconda2 on my Mac. By default Conda is configured to activate the base environment when I open a fresh terminal session.
I want access to the Conda commands (i.e. I want the path to Conda added to my $PATH which Conda does when initialised so that's fine).
However I don't ordinarily program in python, and I don't want Conda to activate the base environment by default.
When first executing conda init from the prompt, Conda adds the following to my .bash_profile:
# >>> conda initialize >>>
# !! Contents within this block are managed by 'conda init' !!
__conda_setup="$('/Users/geoff/anaconda2/bin/conda' 'shell.bash' 'hook' 2> /dev/null)"
if [ $? -eq 0 ]; then
eval "$__conda_setup"
else
if [ -f "/Users/geoff/anaconda2/etc/profile.d/conda.sh" ]; then
. "/Users/geoff/anaconda2/etc/profile.d/conda.sh"
else
export PATH="/Users/geoff/anaconda2/bin:$PATH"
fi
# fi
unset __conda_setup
# <<< conda initialize <<<
If I comment out the whole block, then I can't activate any Conda environments.
I tried to comment out the whole block except for
export PATH="/Users/geoff/anaconda2/bin:$PATH"
But then when I started a new session and tried to activate an environment, I got this error message:
CommandNotFoundError: Your shell has not been properly configured to use 'conda activate'.
This question (and others like it) are helpful, but doesn't ultimately answer my question and is more suited for linux users.
To be clear, I'm not asking to remove the (base) from my $PS1 I'm asking for Conda not to activate base when I open a terminal session.
I have conda 4.6 with a similar block of code that was added by conda. In my case, there's a conda configuration setting to disable the automatic base activation:
conda config --set auto_activate_base false
The first time you run it, it'll create a .condarc in your home directory with that setting to override the default.
This wouldn't de-clutter your .bash_profile but it's a cleaner solution without manual editing that section that conda manages.
There're 3 ways to achieve this after conda 4.6. (The last method has the highest priority.)
Use sub-command conda config to change the setting.
conda config --set auto_activate_base false
In fact, the former conda config sub-command is changing configuration file .condarc. We can modify .condarc directly. Add following content into .condarc under your home directory,
# auto_activate_base (bool)
# Automatically activate the base environment during shell
# initialization. for `conda init`
auto_activate_base: false
Set environment variable CONDA_AUTO_ACTIVATE_BASE in the shell's init file. (.bashrc for bash, .zshrc for zsh)
export CONDA_AUTO_ACTIVATE_BASE=false
To convert from the condarc file-based configuration parameter name to the environment variable parameter name, make the name all uppercase and prepend CONDA_. For example, conda’s always_yes configuration parameter can be specified using a CONDA_ALWAYS_YES environment variable.
The environment settings take precedence over corresponding settings in .condarc file.
References
The Conda Configuration Engine for Power Users
Using the .condarc conda configuration file
conda config --describe
Conda 4.6 Release
The answer depends a little bit on the version of conda that you have installed. For versions of conda >= 4.4, it should be enough to deactivate the conda environment after the initialization, so add
conda deactivate
right underneath
# <<< conda initialize <<<
To disable auto activation of conda base environment in terminal:
conda config --set auto_activate_base false
To activate conda base environment:
conda activate
So in the end I found that if I commented out the Conda initialisation block like so:
# >>> conda initialize >>>
# !! Contents within this block are managed by 'conda init' !!
# __conda_setup="$('/Users/geoff/anaconda2/bin/conda' 'shell.bash' 'hook' 2> /dev/null)"
# if [ $? -eq 0 ]; then
# eval "$__conda_setup"
# else
if [ -f "/Users/geoff/anaconda2/etc/profile.d/conda.sh" ]; then
. "/Users/geoff/anaconda2/etc/profile.d/conda.sh"
else
export PATH="/Users/geoff/anaconda2/bin:$PATH"
fi
# fi
# unset __conda_setup
# <<< conda initialize <<<
It works exactly how I want. That is, Conda is available to activate an environment if I want, but doesn't activate by default.
If you manage your .bashrc manually and like to keep it simple, all you really need is:
. "$HOME/anaconda2/etc/profile.d/conda.sh"
See Recommended change to enable conda in your shell.
This will make the conda command available without activating the base environment (nor reading your conda config).
Note that this is (of course) not compatible with managing the conda installation with conda init, but other than that, nothing bad is coming from it. You may even experience a significant speedup compared to the conda init generated code, because this solution avoids calling conda to parse your config files on whether to enable the base environment, etc.
It's best to also keep the if/fi lines to avoid error messages if using the same bashrc on several systems where conda may not be installed:
if [ -f "$HOME/anaconda2/etc/profile.d/conda.sh" ]; then
. "$HOME/anaconda2/etc/profile.d/conda.sh"
fi
Finally, if you share your bashrc between several systems where conda may be installed in different paths, you could do as follows:
for CONDA_PREFIX in \
"$HOME/anaconda2" \
"$HOME/miniconda3" \
"/opt/miniconda3" \
do
if [ -f "$CONDA_PREFIX/etc/profile.d/conda.sh" ]; then
. "$CONDA_PREFIX/etc/profile.d/conda.sh"
break
fi
done
Of course, this is now similar in length compared to the conda init generated code, but will still execute much faster, and will likely work better than conda init for users who synchronize their .bashrc between different systems.
for conda 4.12.0 (under WOS) the following worked (where all the previous answers -these included- didn't do the trick):
in your activate.bat file (mine was at ~/miniconda3/Scripts/activate.bat), change the line:
#REM This may work if there are spaces in anything in %*
#CALL "%~dp0..\condabin\conda.bat" activate %*
into
#REM This may work if there are spaces in anything in %*
#CALL "%~dp0..\condabin\conda.bat" deactivate
this line chage/modification doesn't work in the section (of the activate.bat file):
#if "%_args1_first%"=="+" if NOT "%_args1_last%"=="+" (
#CALL "%~dp0..\condabin\conda.bat" activate
#GOTO :End
)
maybe because it depends on how your miniconda3 (Anaconda Prompt) executable is set up: %windir%\System32\cmd.exe "/K" some-path-to\miniconda3\Scripts\activate.bat some-path-to\miniconda3 (in my case).
caveat: updating conda overwrites this (activate.bat) file; so one has to modify the above line as many times as needed/updated. not much of a deal-breaker if you ask me.
This might be a bug of the recent anaconda. What works for me:
step1: vim /anaconda/bin/activate, it shows:
#!/bin/sh
_CONDA_ROOT="/anaconda"
# Copyright (C) 2012 Anaconda, Inc
# SPDX-License-Identifier: BSD-3-Clause
\. "$_CONDA_ROOT/etc/profile.d/conda.sh" || return $?
conda activate "$#"
step2: comment out the last line: # conda activate "$#"
One thing that hasn't been pointed out, is that there is little to no difference between not having an active environment and and activating the base environment, if you just want to run applications from Conda's (Python's) scripts directory (as #DryLabRebel wants).
You can install and uninstall via conda and conda shows the base environment as active - which essentially it is:
> echo $Env:CONDA_DEFAULT_ENV
> conda env list
# conda environments:
#
base * F:\scoop\apps\miniconda3\current
> conda activate
> echo $Env:CONDA_DEFAULT_ENV
base
> conda env list
# conda environments:
#
base * F:\scoop\apps\miniconda3\current

Resources