Reputation: 33
I have created a Conda environment in Pycharm called Practice using Python3.7. I am using a Mac and using the Pycharm terminal (fish) however i receive the same error using iterm2.
when i type conda activate Practice
i receive the following error:
Traceback (most recent call last):
File "/usr/local/anaconda3/lib/python3.7/site-packages/conda/cli/main.py", line 138, in main
return activator_main()
File "/usr/local/anaconda3/lib/python3.7/site-packages/conda/activate.py", line 1098, in main
print(activator.execute(), end='')
File "/usr/local/anaconda3/lib/python3.7/site-packages/conda/activate.py", line 182, in execute
return getattr(self, self.command)()
File "/usr/local/anaconda3/lib/python3.7/site-packages/conda/activate.py", line 156, in activate
builder_result = self.build_activate(self.env_name_or_prefix)
File "/usr/local/anaconda3/lib/python3.7/site-packages/conda/activate.py", line 301, in build_activate
return self._build_activate_stack(env_name_or_prefix, False)
File "/usr/local/anaconda3/lib/python3.7/site-packages/conda/activate.py", line 378, in _build_activate_stack
self._replace_prefix_in_path(old_conda_prefix, prefix))
File "/usr/local/anaconda3/lib/python3.7/site-packages/conda/activate.py", line 628, in _replace_prefix_in_path
if path_list[last_idx + 1] == library_bin_dir:
IndexError: list index out of range
`$ /usr/local/anaconda3/bin/conda shell.fish activate Practice`
environment variables:
CIO_TEST=<not set>
CONDA_DEFAULT_ENV=base
CONDA_PREFIX=/usr/local/anaconda3
CONDA_PROMPT_MODIFIER=(base)
CONDA_PYTHON_EXE=/usr/local/anaconda3/bin/python
CONDA_ROOT=/usr/local/anaconda3
CONDA_SHLVL=1
PATH=/usr/local/anaconda3/bin:/usr/local/anaconda3/condabin:/usr/local/bin:
/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/anaconda3/bin
REQUESTS_CA_BUNDLE=<not set>
SSL_CERT_FILE=<not set>
active environment : base
active env location : /usr/local/anaconda3
shell level : 1
user config file : /Users/RossRoberts/.condarc
populated config files : /Users/RossRoberts/.condarc
conda version : 4.8.0
conda-build version : 3.18.8
python version : 3.7.3.final.0
virtual packages : __osx=10.14.6
base environment : /usr/local/anaconda3 (writable)
channel URLs : https://conda.anaconda.org/conda-forge/osx-64
https://conda.anaconda.org/conda-forge/noarch
https://repo.anaconda.com/pkgs/main/osx-64
https://repo.anaconda.com/pkgs/main/noarch
https://repo.anaconda.com/pkgs/r/osx-64
https://repo.anaconda.com/pkgs/r/noarch
package cache : /usr/local/anaconda3/pkgs
/Users/RossRoberts/.conda/pkgs
envs directories : /usr/local/anaconda3/envs
/Users/RossRoberts/.conda/envs
platform : osx-64
user-agent : conda/4.8.0 requests/2.22.0 CPython/3.7.3 Darwin/18.7.0 OSX/10.14.6
UID:GID : 502:20
netrc file : None
offline mode : False
An unexpected error has occurred. Conda has prepared the above report.
i have already run conda init fish
and restarted my shell and even tried restarting the machine and i'm still receiving the same error.
This issue is preventing me from running code because my project interpreter is configured to this environment but any time i try to install packages it installs to the active environment (base).
Upvotes: 3
Views: 2934
Reputation: 11
Check your .bashrc or .zshrc config ,modify the conda path config correctly
eg :
vi .zshrc
then
# >>> conda initialize >>>
# !! Contents within this block are managed by 'conda init' !!
__conda_setup="$('/Users/mac/opt/anaconda3/bin/conda' 'shell.zsh' 'hook' 2> /dev/null)"
if [ $? -eq 0 ]; then
eval "$__conda_setup"
else
if [ -f "/Users/mac/opt/anaconda3/etc/profile.d/conda.sh" ]; then
. "/Users/mac/opt/anaconda3/etc/profile.d/conda.sh"
else
export PATH="/Users/mac/opt/anaconda3/bin:$PATH"
fi
fi
unset __conda_setup
# <<< conda initialize <<<
export PATH=/Users/mac/opt/anaconda3/bin:$PATH
chage /Users/mac/opt/anaconda3/bin
to your own path
after change config , remember source your bashrc or zshrc file
source .zshrc
it works a lot , unless the conda path config conflict
Upvotes: 1
Reputation: 1
I had the same issue . The path variable was incorrect . Type echo $PATH
, you will be able to see the current path . I changed that to anaconda directory by executing the following command export PATH=/home/username/anaconda3/bin
. This resolved my issue.
Upvotes: 0
Reputation: 656
I had the same problem. Notice that /usr/local/anaconda3/bin is on your PATH twice. Make sure you aren't putting that directory on your path yourself.
The conda init fish
adds a line to your fish configuration that will create a 'conda' shell function, and by appending /usr/local/anaconda3/bin to your PATH, you are interfering with some assumption that conda init
makes.
Upvotes: 5