python - How to solve the issue of the conflict of anaconda and virtualenv -


i using virtualenv time , had installed anaconda. tried activate virtual environment using way of anaconda source activate helloworld. (indeed don't remember if command typed in). , environment had been activated. when tried run notebook, said libraries didn't exist if had installed them in environment. not until did realize had activated wrong environment. , close tab , cd hellowworld , did source bin/activate. late. got output prepending /home/lcc/anaconda3/envs/bin path , environment not activated expectedly. know how solve issue? thanks!

here full content of activate file under /hello/world:

#!/bin/bash  # determine directory containing script if [[ -n $bash_version ]];     _script_location=${bash_source[0]}     shell="bash" elif [[ -n $zsh_version ]];     _script_location=${funcstack[1]}     shell="zsh" else     echo "only bash , zsh supported"     return 1 fi _conda_dir=$(dirname "$_script_location")  if [ $# -gt 1 ];     (>&2 echo "error: did not expect more 1 argument.")     (>&2 echo "    (got $@)")     return 1 fi  case "$(uname -s)" in     cygwin*|mingw32*|msys*)         ext=".exe"         ;;     *)         ext=""         ;; esac  # export whatever ps setting have, available python subprocesses export ps1  # ensure script sourced, not executed # note errors ignored `activate foo` doesn't generate bad # value $0 cause errors. if [[ -n $bash_version ]] && [[ "$(basename "$0" 2> /dev/null)" == "activate" ]];     (>&2 echo "error: activate must sourced. run 'source activate envname' instead of 'activate envname'. ")     "$_conda_dir/conda" ..activate $shell$ext -h     exit 1 fi  "$_conda_dir/conda" ..checkenv $shell$ext "$@" if (( $? != 0 ));     return 1 fi  # ensure deactivate scripts old env #   note: empties $@.  preserve copy. args=$@ source "$_conda_dir/deactivate"  _new_path=$("$_conda_dir/conda" ..activate $shell$ext "$args") if (( $? == 0 ));     export conda_path_backup="$path"     # export restore upon deactivation     export conda_old_ps1=$ps1      export path="$_new_path"     # first path (should full path prefix of our env)     # inner string extraction pulls off first path     # outer string removes /bin if present (on unix)     firstpath=${path%%:*}     export conda_default_env="$(echo ${firstpath} | sed "s|/bin$||")" &>/dev/null     # legacy support: conda_default_env used either env name or full path if given path.     #    conda_default_env full path.     #    keep conda_env_path around, , have mirror conda_default_env.     #    last date of change: 2016-04-18     export conda_env_path=$conda_default_env      export ps1="$( "$_conda_dir/conda" ..setps1 $shell$ext "$args" )"      # load of scripts found $prefix/etc/conda/activate.d after activation     _conda_d="${conda_default_env}/etc/conda/activate.d"     if [[ -d "$_conda_d" ]];         ifs=$(echo -en "\n\b")&>/dev/null  && f in $(find "$_conda_d" -iname "*.sh"); source "$f"; done     fi else     return $? fi  if [[ -n $bash_version ]];     hash -r elif [[ -n $zsh_version ]];     rehash else     echo "only bash , zsh supported"     return 1 fi 

it's not clear question expect "activate" do. activating virtualenv, or activating conda environment.

when install miniconda or anaconda, given option add path. if so, comes before virtualenv activate script. can rename 1 or other, or create alias virtualenv 1 calls absolute path activate script. can move anaconda it's appended rather prepended, virtualenv activate used rather conda 1 (barring absolute paths).

to append conda's path, in ~/.bashrc or ~/.bash_profile , change

export path=<anaconda path>:$path 

to

export path=$path:<anaconda path> 

Comments

Popular posts from this blog

sequelize.js - Sequelize group by with association includes id -

android - Robolectric "INTERNET permission is required" -

java - Android raising EPERM (Operation not permitted) when attempting to send UDP packet after network connection -