be kind I am very new to coding. I have an unexpected end of file in by bash_profile and I can't debug it. Would someone with more experience mind taking a look and help me get to the bottom of it?
# pipx
export PATH="~/.local/bin:$PATH"
# pyenv
if command -v pyenv 1>/dev/null 2>&1; then
eval "$(pyenv init -)"
fi
# poetry
export PATH="$HOME/.poetry/bin:$PATH"
# pip should only run if there is a virtualenv currently activated
export PIP_REQUIRE_VIRTUALENV=true
# commands to override pip restriction above.
# use `gpip` or `gpip3` to force installation of
# a package in the global python environment
# Never do this! It is just an escape hatch.
gpip(){
PIP_REQUIRE_VIRTUALENV="" pip "$#"
}
gpip3(){
PIP_REQUIRE_VIRTUALENV="" pip3 "$#"
}# added by Anaconda3 2019.07 installer
# >>> conda init >>>
# !! Contents within this block are managed by 'conda init' !!
__conda_setup="$(CONDA_REPORT_ERRORS=false '/anaconda3/bin/conda' shell.bash hook 2> /dev/null)"
if [ $? -eq 0 ]; then
\eval "$__conda_setup"
else
if [ -f "/anaconda3/etc/profile.d/conda.sh" ]; then
. "/anaconda3/etc/profile.d/conda.sh"
CONDA_CHANGEPS1=false conda activate base
else
\export PATH="/anaconda3/bin:$PATH"
fi
fi
unset __conda_setup
# <<< conda init <<<
I suggest to replace }# with } # in line 24.
Related
My problem is almost identical to this question. However the solutions don't work when I use tmux. Usually I first open a terminal (bash) and then start a tmux session.
When I then try to use this solution:
in my ~/.bashrc I add
# >>> conda initialize >>>
# !! Contents within this block are managed by 'conda init' !!
__conda_setup="$('$HOME/miniconda3/bin/conda' 'shell.bash' 'hook' 2> /dev/null)"
if [ $? -eq 0 ]; then
eval "$__conda_setup"
else
if [ -f "$HOME/miniconda3/etc/profile.d/conda.sh" ]; then
. "$HOME/miniconda3/etc/profile.d/conda.sh"
else
export PATH="$HOME/miniconda3/bin:$PATH"
fi
fi
unset __conda_setup
# <<< conda initialize <<<
# Here comes the code to switch between conda and pyenv:
switch_pyenv(){
conda deactivate
conda deactivate # in case you're not in base env
eval "$(pyenv init -)"
eval "$(pyenv virtualenv-init -)"
}
switch_conda(){
conda activate base
export PATH="$HOME/miniconda3/bin:$PATH"
}
# quick check which python, pip
w(){
which python
which pip
python --version
}
However whenever I open tmux, the switching fails with the error message:
_pyenv_virtualenv_hook: command not found
After installing new packages using pip3 in my Conda env, I am not able to importing them in jupyter.
(base) MacBook-Air:~ johnsmith$ which python
/usr/bin/python
Looking at other posts, I understand this means that my default python is not the condo python install so I'm not getting the packages installed to the correct location. Also looking at other posts, I think I might need to fix my .bash_profile file to point pip3 to the right python version. Unfortunately, the file looks messy with several conda initializations. Maybe these are leftovers from previous condo installs. How do I fix this bash file? (I changed the user name but otherwise the file is identical).
export LD_LIBRARY_PATH=/Users/johnsmith/homework/mjpro131/bin
export PATH="$LD_LIBRARY_PATH:$PATH"
# added by Anaconda3 2019.10 installer
# >>> conda init >>>
# !! Contents within this block are managed by 'conda init' !!
__conda_setup="$(CONDA_REPORT_ERRORS=false '/opt/anaconda3/bin/conda' shell.bash hook 2> /dev/null)"
if [ $? -eq 0 ]; then
\eval "$__conda_setup"
else
if [ -f "/opt/anaconda3/etc/profile.d/conda.sh" ]; then
# . "/opt/anaconda3/etc/profile.d/conda.sh" # commented out by conda initialize
CONDA_CHANGEPS1=false conda activate base
else
\export PATH="/opt/anaconda3/bin:$PATH"
fi
fi
unset __conda_setup
# <<< conda init <<<
# >>> conda initialize >>>
# !! Contents within this block are managed by 'conda init' !!
__conda_setup="$('/Users/johnsmith/opt/anaconda3/bin/conda' 'shell.bash' 'hook' 2> /dev/null)"
if [ $? -eq 0 ]; then
eval "$__conda_setup"
else
if [ -f "/Users/johnsmith/opt/anaconda3/etc/profile.d/conda.sh" ]; then
. "/Users/johnsmith/opt/anaconda3/etc/profile.d/conda.sh"
else
export PATH="/Users/johnsmith/opt/anaconda3/bin:$PATH"
fi
fi
unset __conda_setup
# <<< conda initialize <<<
I am completely new to python and bash. I uninstalled Anaconda using conda clean and deleted the .anaconda_backup in my home directory. I opened the .bash_profile and did see
export PATH="/Users/XXXXX/anaconda3/bin:$PATH" and few other instances of $PATH appended.
My .bash_profile
# added by Anaconda3 5.3.1 installer
# >>> conda init >>>
# !! Contents within this block are managed by 'conda init' !!
__conda_setup="$(CONDA_REPORT_ERRORS=false '/Users/XXXXXXXXXX/anaconda3/bin/conda' shell.bash hook 2> /dev/null)"
if [ $? -eq 0 ]; then
\eval "$__conda_setup"
else
if [ -f "/Users/XXXXXXXXXX/anaconda3/etc/profile.d/conda.sh" ]; then
# . "/Users/XXXXXXXXXX/anaconda3/etc/profile.d/conda.sh" # commented out by conda initialize
CONDA_CHANGEPS1=false conda activate base
else
\export PATH="/Users/XXXXXXXXXX/anaconda3/bin:$PATH"
fi
fi
unset __conda_setup
# <<< conda init <<<
##
# Your previous /Users/XXXXXXXXXX/.bash_profile file was backed up as /Users/XXXXXXXXXX/.bash_profile.macports-saved_2019-01-19_at_19:04:16
##
# MacPorts Installer addition on 2019-01-19_at_19:04:16: adding an appropriate PATH variable for use with MacPorts.
export PATH="/opt/local/bin:/opt/local/sbin:$PATH"
# Finished adapting your PATH environment variable for use with MacPorts.
# added by Anaconda3 2019.10 installer
# >>> conda init >>>
# !! Contents within this block are managed by 'conda init' !!
__conda_setup="$(CONDA_REPORT_ERRORS=false '/Users/XXXXXXXXXX/opt/anaconda3/bin/conda' shell.bash hook 2> /dev/null)"
if [ $? -eq 0 ]; then
\eval "$__conda_setup"
else
if [ -f "/Users/XXXXXXXXXX/opt/anaconda3/etc/profile.d/conda.sh" ]; then
# . "/Users/XXXXXXXXXX/opt/anaconda3/etc/profile.d/conda.sh" # commented out by conda initialize
CONDA_CHANGEPS1=false conda activate base
else
\export PATH="/Users/XXXXXXXXXX/opt/anaconda3/bin:$PATH"
fi
fi
unset __conda_setup
# <<< conda init <<<
# >>> conda initialize >>>
# !! Contents within this block are managed by 'conda init' !!
__conda_setup="$('/opt/anaconda3/bin/conda' 'shell.bash' 'hook' 2> /dev/null)"
if [ $? -eq 0 ]; then
eval "$__conda_setup"
else
if [ -f "/opt/anaconda3/etc/profile.d/conda.sh" ]; then
. "/opt/anaconda3/etc/profile.d/conda.sh"
else
export PATH="/opt/anaconda3/bin:$PATH"
fi
fi
unset __conda_setup
# <<< conda initialize <<<
However, I didn't actually understood the part related to removing the Anaconda path from .bash_profile given in the manual. I ran echo $PATH again after uninstalling Anaconda and it looks exactly like before when i had Anaconda.
/opt/anaconda3/bin:/Users/XXXXX/opt/anaconda3/bin:/opt/local/bin:/opt/local/sbin:/Users/XXXXX/anaconda3/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin
I plan to install miniconda and create an environment for learning data science. I am trying to force myself to get more and more acquainted to terminal
Is it still safe to go ahead and install the Miniconda? How do I remove Anaconda path from .bash_profile? Will I be still able to open python by just typing the python command? or I would need to add a different path to access python after installing python through miniconda?
I installed Anaconda on my Mac (Mojave) and now whenever I start a shell it automatically activates the conda environment. This was totally fine until I realized some of the commands in my .bashrc were not being executed on startup. In particular, I had increased HISTSIZE and HISTFILESIZE but they always seemed to be stuck at their default values of 500. After some googling, I learnt that because of my anaconda installation, it was my .bash_profile that was being used on startup and not .bashrc. This is what my .bash_profile looks like (see below), just adding commands from my .bashrc file (e.g., HISTFILESIZE=100000) to the top of my .bash_profile appears to do nothing. Any suggestions on what I am doing wrong? Thanks!
# 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.07 installer
# >>> conda init >>>
# !! Contents within this block are managed by 'conda init' !!
__conda_setup="$(CONDA_REPORT_ERRORS=false '/anaconda3/bin/conda' shell.bash hook 2> /dev/null)"
if [ $? -eq 0 ]; then
\eval "$__conda_setup"
else
if [ -f "/anaconda3/etc/profile.d/conda.sh" ]; then
# . "/anaconda3/etc/profile.d/conda.sh" # commented out by conda initialize
CONDA_CHANGEPS1=false conda activate base
else
\export PATH="/anaconda3/bin:$PATH"
fi
fi
unset __conda_setup
# <<< conda init <<<
# >>> conda initialize >>>
# !! Contents within this block are managed by 'conda init' !!
__conda_setup="$('//anaconda3/bin/conda' 'shell.bash' 'hook' 2> /dev/null)"
if [ $? -eq 0 ]; then
eval "$__conda_setup"
else
if [ -f "//anaconda3/etc/profile.d/conda.sh" ]; then
. "//anaconda3/etc/profile.d/conda.sh"
else
export PATH="//anaconda3/bin:$PATH"
fi
fi
unset __conda_setup
# <<< conda initialize <<<
You can try to add the following lines in the bash_profile as suggested Here:
if [ -f ~/.bashrc ]; then
source ~/.bashrc
fi
I installed Anaconda on MacOS. I tried to run the conda command in terminal, but I got the following error message:
****/Users/rodalbert/.anaconda/navigator/a.tool ; exit;
/Users/rodalbert/.bash_profile:export:3: not an identifier: 2018.12
➜ ~ /Users/rodalbert/.anaconda/navigator/a.tool ; exit;
/Users/rodalbert/.anaconda/navigator/a.tool: line 1: syntax error near unexpected token `('
/Users/rodalbert/.anaconda/navigator/a.tool: line 1: `bash --init-file <(echo "source activate /Users/rodalbert/anaconda3;")'
[Process completed]****
I can't find the problem. Does someone know what to do in this case?
Content of .bash_profile
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function*
export PATH=/Applications/Postgres.app/Contents/Versions/11/bin/psql:$PATH# added by Anaconda3 2018.12 installer
# >>> conda init >>>
# !! Contents within this block are managed by 'conda init' !!
__conda_setup="$(CONDA_REPORT_ERRORS=false '/anaconda3/bin/conda' shell.bash hook 2> /dev/null)"
if [ $? -eq 0 ]; then
\eval "$__conda_setup"
else
if [ -f "/anaconda3/etc/profile.d/conda.sh" ]; then
. "/anaconda3/etc/profile.d/conda.sh"
CONDA_CHANGEPS1=false conda activate base
else
\export PATH="/anaconda3/bin:$PATH"
fi
fi
unset __conda_setup
# <<< conda init <<<
# added by Anaconda3 2018.12 installer
# >>> conda init >>>
# !! Contents within this block are managed by 'conda init' !!
__conda_setup="$(CONDA_REPORT_ERRORS=false '/Users/rodalbert/anaconda3/bin/conda' shell.bash hook 2> /dev/null)"
if [ $? -eq 0 ]; then
\eval "$__conda_setup"
else
if [ -f "/Users/rodalbert/anaconda3/etc/profile.d/conda.sh" ]; then
. "/Users/rodalbert/anaconda3/etc/profile.d/conda.sh"
CONDA_CHANGEPS1=false conda activate base
else
\export PATH="/Users/rodalbert/anaconda3/bin:$PATH"
fi
fi
unset __conda_setup
# <<< conda init <<<
It seems like you're using Zsh.
Before executing any command from within Anaconda Navigator, try opening your Terminal app and switching shell to bash: chsh -s /bin/bash then restart terminal.
After you're done with Anaconda, switch back to Zsh: chsh -s /bin/zsh then restart terminal.
I used MohammadChavos's solution, then conda can run on the terminal.
cd /path/to/anaconda/bin
./conda init zsh
or:
zsh conda init zsh
My case: cd opt/anaconda3/bin, then run: ./conda init zsh