3
votes

I installed anaconda3 using the standard settings and mainly use tcsh. If terminal opens in tcsh and then I type "conda" it works. If I type "python" it shows

Python 2.7.10 (default, Feb  7 2017, 00:08:15) 
[GCC 4.2.1 Compatible Apple LLVM 8.0.0 (clang-800.0.34)] on darwin
Type "help", "copyright", "credits" or "license" for more information.

But, if I type "bash" and then "tcsh" and then "python" it shows this:

Python 3.6.2 |Anaconda, Inc.| (default, Sep 21 2017, 18:29:43) 
[GCC 4.2.1 Compatible Clang 4.0.1 (tags/RELEASE_401/final)] on darwin
Type "help", "copyright", "credits" or "license" for more information.

For reference, my .tcshrc file contains this:

set path  = ( $path anaconda3/bin . /opt/local/bin /opt/local/ncbi/blast )

alias python2 '/opt/local/Library/Frameworks/Python.framework/Versions/2.7/bin/python2.7'

alias python3 '/opt/local/Library/Frameworks/Python.framework/Versions/3.5/bin/python3.5'

.bashrc contains:

export PATH=~/anaconda3/bin:$PATH

.bash_profile contains:

source ~/.bashrc
PATH=$PATH:$HOME/anaconda3/bin
export PATH="/anaconda3/bin:$PATH"

I'm new to Unix and Python but need to set up anaconda in both bash and tcsh for a class. Any ideas?

update:

"which python" yields "/usr/bin/python" when I start up terminal in tcsh

If I switch to bash, "which python" yields "/anaconda3/bin/python"

"echo $PATH" in tcsh yields "/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:anaconda3/bin:.:/opt/local/bin:/opt/local/ncbi/blast"

"echo $PATH" in bash yields "/anaconda/bin:/anaconda3/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:anaconda3/bin:.:/opt/local/bin:/opt/local/ncbi/blast"

1
Please type which python for each case. This will show the path to the python binary the shell will be using. It may also be illuminating to type echo $PATH for each case as well. It seems like in your bash startup scripts you are doing a lot of PATH modification.SethMMorton
In bash type: echo $PATH and which python to see your PATH and see what python-interpreter you're using.René Pijl
@SethMMorton updated aboveAAA
@AAA I bet that's not what your PATH looks like in tcsh before you switch to bash.SethMMorton
@SethMMorton yeah you were right. changed ^AAA

1 Answers

2
votes

First, please take a look at this question and its answers to understand how the PATH environment variable works: https://unix.stackexchange.com/questions/77898/how-does-the-path-enviroment-variable-work-in-linux.

Your issue is that in your ~/.tcshrc you are not adding the Anaconda directory to the front your PATH, so tcsh finds the system installation first and uses that. To fix this you can modify the first line of that file to read:

setenv PATH ~/anaconda3/bin:$PATH:.:/opt/local/bin:/opt/local/ncbi/blast

In tcsh, setenv serves a similar purpose to export in bash, so using just set would not reliably change your PATH.

As a side note, you appear to be making the same modification to your bash PATH over and over... you could clean that up a bit.