title: Anaconda selecting correct enrivonment but wrong sys.path?
body: <p>I have different anaconda environments. When starting up one of them it seems as if <code>sys.path</code> is still set to some totally wrong directory. Am I not understanding the concepts of environments correctly or is this an error concerning my anaconda setup?</p>
  
  <p>My environments:</p>
  
  <pre><code>fabianwerner ~$ conda env list
  # conda environments:
  #
  base                  *  /Users/fabianwerner/anaconda3/anaconda3
  my-rdkit-env             /Users/fabianwerner/anaconda3/anaconda3/envs/my-rdkit-env
  openpose                 /Users/fabianwerner/anaconda3/anaconda3/envs/openpose
  
  fabianwerner ~$ 
  </code></pre>
  
  <p>I activate the environment 'openpose':</p>
  
  <pre><code>fabianwerner ~$ conda activate openpose
  (openpose) fabianwerner ~$ 
  </code></pre>
  
  <p>I will try to import 'keras' so let us make sure that it is installed:</p>
  
  <pre><code>(openpose) fabianwerner ~$ pip list | grep -i keras
  DEPRECATION: The default format will switch to columns in the future. You can use --format=(legacy|columns) (or define a format=(legacy|columns) in your pip.conf under the [list] section) to disable this warning.
  Keras (2.2.4)
  Keras-Applications (1.0.7)
  Keras-Preprocessing (1.0.9)
  You are using pip version 9.0.1, however version 19.1.1 is available.
  You should consider upgrading via the 'pip install --upgrade pip' command.
  (openpose) fabianwerner ~$ 
  </code></pre>
  
  <p>I start python and try to import keras:</p>
  
  <pre><code>(openpose) fabianwerner ~$ python
  Python 3.6.5 |Anaconda, Inc.| (default, Apr 26 2018, 08:42:37) 
  [GCC 4.2.1 Compatible Clang 4.0.1 (tags/RELEASE_401/final)] on darwin
  Type "help", "copyright", "credits" or "license" for more information.
  &gt;&gt;&gt; import keras
  Traceback (most recent call last):
    File "&lt;stdin&gt;", line 1, in &lt;module&gt;
  ModuleNotFoundError: No module named 'keras'
  &gt;&gt;&gt; 
  </code></pre>
  
  <p>Let us check where python looks for modules:</p>
  
  <pre><code>&gt;&gt;&gt; import sys
  &gt;&gt;&gt; print(sys.path)   
  ['', '/Users/fabianwerner/anaconda3/anaconda3/envs/my-rdkit-env/lib/python36.zip', '/Users/fabianwerner/anaconda3/anaconda3/envs/my-rdkit-env/lib/python3.6', '/Users/fabianwerner/anaconda3/anaconda3/envs/my-rdkit-env/lib/python3.6/lib-dynload', '/Users/fabianwerner/.local/lib/python3.6/site-packages', '/Users/fabianwerner/anaconda3/anaconda3/envs/my-rdkit-env/lib/python3.6/site-packages']
  &gt;&gt;&gt; 
  </code></pre>
  
  <p>so I activated the environment 'openpose' but it still looks for modules in the other (wrong!) environment 'my-rdkit-env'!</p>
  
  <p>How to fix this?</p>
  
  <p>EDIT:</p>
  
  <p>I cannot see any obvious problem with the anaconda setup as conda info -a gives the right path:</p>
  
  <pre><code>(openpose) fabianwerner ~$ conda info -a
  
       active environment : openpose
      active env location : /Users/fabianwerner/anaconda3/anaconda3/envs/openpose
              shell level : 2
         user config file : /Users/fabianwerner/.condarc
   populated config files : 
            conda version : 4.5.11
      conda-build version : 3.15.1
           python version : 3.7.0.final.0
         base environment : /Users/fabianwerner/anaconda3/anaconda3  (writable)
             channel URLs : https://repo.anaconda.com/pkgs/main/osx-64
                            https://repo.anaconda.com/pkgs/main/noarch
                            https://repo.anaconda.com/pkgs/free/osx-64
                            https://repo.anaconda.com/pkgs/free/noarch
                            https://repo.anaconda.com/pkgs/r/osx-64
                            https://repo.anaconda.com/pkgs/r/noarch
                            https://repo.anaconda.com/pkgs/pro/osx-64
                            https://repo.anaconda.com/pkgs/pro/noarch
            package cache : /Users/fabianwerner/anaconda3/anaconda3/pkgs
                            /Users/fabianwerner/.conda/pkgs
         envs directories : /Users/fabianwerner/anaconda3/anaconda3/envs
                            /Users/fabianwerner/.conda/envs
                 platform : osx-64
               user-agent : conda/4.5.11 requests/2.19.1 CPython/3.7.0 Darwin/17.7.0 OSX/10.13.6
                  UID:GID : 502:20
               netrc file : None
             offline mode : False
  
  # conda environments:
  #
  base                     /Users/fabianwerner/anaconda3/anaconda3
  my-rdkit-env             /Users/fabianwerner/anaconda3/anaconda3/envs/my-rdkit-env
  openpose              *  /Users/fabianwerner/anaconda3/anaconda3/envs/openpose
  strokinat0r              /Users/fabianwerner/anaconda3/anaconda3/envs/strokinat0r
  
  sys.version: 3.7.0 (default, Jun 28 2018, 07:39:16) 
  ...
  sys.prefix: /Users/fabianwerner/anaconda3/anaconda3
  sys.executable: /Users/fabianwerner/anaconda3/anaconda3/bin/python
  conda location: /Users/fabianwerner/anaconda3/anaconda3/lib/python3.7/site-packages/conda
  conda-build: /Users/fabianwerner/anaconda3/anaconda3/bin/conda-build
  conda-convert: /Users/fabianwerner/anaconda3/anaconda3/bin/conda-convert
  conda-develop: /Users/fabianwerner/anaconda3/anaconda3/bin/conda-develop
  conda-env: /Users/fabianwerner/anaconda3/anaconda3/bin/conda-env
  conda-index: /Users/fabianwerner/anaconda3/anaconda3/bin/conda-index
  conda-inspect: /Users/fabianwerner/anaconda3/anaconda3/bin/conda-inspect
  conda-metapackage: /Users/fabianwerner/anaconda3/anaconda3/bin/conda-metapackage
  conda-render: /Users/fabianwerner/anaconda3/anaconda3/bin/conda-render
  conda-server: /Users/fabianwerner/anaconda3/anaconda3/bin/conda-server
  conda-skeleton: /Users/fabianwerner/anaconda3/anaconda3/bin/conda-skeleton
  user site dirs: ~/.local/lib/python3.6
  
  CIO_TEST: &lt;not set&gt;
  CONDA_DEFAULT_ENV: openpose
  CONDA_EXE: /Users/fabianwerner/anaconda3/anaconda3/bin/conda
  CONDA_PREFIX: /Users/fabianwerner/anaconda3/anaconda3/envs/openpose
  CONDA_PREFIX_1: /Users/fabianwerner/anaconda3/anaconda3
  CONDA_PROMPT_MODIFIER: (openpose) 
  CONDA_PYTHON_EXE: /Users/fabianwerner/anaconda3/anaconda3/bin/python
  CONDA_ROOT: /Users/fabianwerner/anaconda3/anaconda3
  CONDA_SHLVL: 2
  PATH: /Users/fabianwerner/anaconda3/anaconda3/envs/openpose/bin:/Users/fabianwerner/anaconda3/anaconda3/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Applications/GIMP-2.10.app/Contents/MacOS
  REQUESTS_CA_BUNDLE: &lt;not set&gt;
  SSL_CERT_FILE: &lt;not set&gt;
  
  
  WARNING: could not import _license.show_info
  # try:
  # $ conda install -n root _license
  (openpose) fabianwerner ~$ 
  </code></pre>
  
  <p>Also, I do not seem to have an environment variable set that relates to python:</p>
  
  <pre><code>(openpose) fabianwerner ~$ printenv | grep -i python
  CONDA_PYTHON_EXE=/Users/fabianwerner/anaconda3/anaconda3/bin/python
  (openpose) fabianwerner ~$ 
  </code></pre>
  
  <p>My setup:</p>
  
  <ul>
  <li>Mac OS-X 10.13.6 (High Sierra)</li>
  <li>anaconda version 4.5.11</li>
  </ul>
  
  <p>Thanks,</p>
  
  <p>FW</p>