Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

crashing anaconda envs on activation #662

Closed
jmccormac01 opened this issue Jul 22, 2016 · 5 comments
Closed

crashing anaconda envs on activation #662

jmccormac01 opened this issue Jul 22, 2016 · 5 comments

Comments

@jmccormac01
Copy link

jmccormac01 commented Jul 22, 2016

Hi, I am trying to install astroconda for work. I manage my python versions with pyenv. I've installed a specific installation of anaconda-4.0.0 with pyenv so I can set up an astroconda env. When I follow the instructions on the astroconda RTD page and then try to activate the env with

source activate astroconda

it crashes the terminal window completely. At first I thought this might be an astroconda issue, but now I am not sure. I tried making a throwaway env as suggested to my issue on the astroconda repo. When I do this the terminal still crashes. I think the modified activate script in .shims might be causing the problem?

Any help would be great, thanks. Below is a screen shot of the terminal output right before it dies.
Cheers,
James

screen shot 2016-07-22 at 12 54 31

@nicktimko
Copy link
Contributor

What do you mean by "crashes"? Freezes? Does Ctrl-C (SIGTERM) or Ctrl-D (EOF) bring it back?

This is probably an issue with Anaconda and/or your shell (what shell are you using?); source might be doing something strange like interpreting its arguments as a command to evaluate, which is why Anaconda is printing that error that tells you to use source even though you did.

@yyuu
Copy link
Contributor

yyuu commented Aug 15, 2016

I could not reproduce the issue.

It seems that one of astroconda's dependencies install custom profile script. Though it just worked fine for me at least.

% pyenv sh-activate miniconda3-4.0.5/envs/astroconda
unset PYENV_VIRTUAL_ENV;
unset VIRTUAL_ENV;
if [ -n "${_OLD_VIRTUAL_PATH}" ]; then
  export PATH="${_OLD_VIRTUAL_PATH}";
  unset _OLD_VIRTUAL_PATH;
fi;
if [ -n "${_OLD_VIRTUAL_PYTHONHOME}" ]; then
  export PYTHONHOME="${_OLD_VIRTUAL_PYTHONHOME}";
  unset _OLD_VIRTUAL_PYTHONHOME;
fi;
if [ -n "${_OLD_VIRTUAL_PS1}" ]; then
  export PS1="${_OLD_VIRTUAL_PS1}";
  unset _OLD_VIRTUAL_PS1;
fi;
if declare -f deactivate 1>/dev/null 2>&1; then
  unset -f deactivate;
fi;
export PYENV_VERSION="miniconda3-4.0.5/envs/astroconda";
export PYENV_ACTIVATE_SHELL=1;
export PYENV_VIRTUAL_ENV="/home/yyuu/.pyenv/versions/miniconda3-4.0.5/envs/astroconda";
export VIRTUAL_ENV="/home/yyuu/.pyenv/versions/miniconda3-4.0.5/envs/astroconda";
export CONDA_DEFAULT_ENV="astroconda";
. "/home/yyuu/.pyenv/versions/miniconda3-4.0.5/envs/astroconda/etc/conda/activate.d/webbpsf-data.sh";

@yyuu yyuu closed this as completed Aug 15, 2016
@pocin
Copy link

pocin commented Dec 25, 2016

Hi, I have exactly the same issue. I ran exactly these commands

  1. $ brew install pyenv
  2. add PYENV_ROOT=/usr/local/var/pyenv/ and if which pyenv > /dev/null; then eval "$(pyenv init -)"; fi (in this order) to .zshrc
  3. run $ conda create -n data requests and pyenv local miniconda3-latest and pyenv global miniconda3-latest.
  4. Restart shell.
  5. At this point $ which activate outputs /usr/local/var/pyenv/shims/activate. and
$ pyenv versions
  system
* miniconda3-latest (set by /Users/pocin/.python-version)
  miniconda3-latest/envs/data
  1. and the problem: $source activate data exits the terminal with the message "Error: activate must be sourced. Run source activate envname instead of activate envname.
  2. $ which source yields source: shell built-in command

If i cd into /usr/local/var/pyenv/versions/miniconda3-latest/bin and run $source activate data the env gets activated and it works. I suppose there is a problem with the activate shim?
Here are the contents of /usr/local/var/pyenv/shims/activate

#!/usr/bin/env bash
set -e
[ -n "$PYENV_DEBUG" ] && set -x

program="${0##*/}"
if [[ "$program" = "python"* ]]; then
  for arg; do
    case "$arg" in
    -c* | -- ) break ;;
    */* )
      if [ -f "$arg" ]; then
        export PYENV_FILE_ARG="$arg"
        break
      fi
      ;;
    esac
  done
fi

export PYENV_ROOT="/usr/local/var/pyenv"
exec "/usr/local/Cellar/pyenv/1.0.6/libexec/pyenv" exec "$program" "$@"

I will happily provide more info

@yyuu
Copy link
Contributor

yyuu commented Dec 26, 2016

@pocin the activate script of virtualenv and anaconda will not work without trick in pyenv since the shim script generated by pyenv is created for executables 😞 Even if the activate script works with pyenv, because the script will manage $PATH of user's interactive shell, unfortunately it won't work well with pyenv's shim scripts.

As a workaround, I've prepared support for Anaconda style activation in pyenv-virtualenv. I'd recommend Anaconda users to install pyenv-virtualenv if they'd like to use pyenv style versioning with conda's environments. Please give it a try.

https://github.com/yyuu/pyenv-virtualenv/tree/a3bc42cb93c5758ae967b4637829826800053689#anaconda-and-miniconda

@pocin
Copy link

pocin commented Dec 26, 2016

@yyuu oh thanks! I'll give it a shot :) I had a feeling it was not a bug, but I just could not find any mention of pyenv-virtualenv in the docs. Perhaps a small note/link could be added?
Thanks for your good work 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants