Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why has Anaconda added my default Python paths to the specific environment's path?

I have created an anaconda environment. When I activate the environment I can see that the environment is using a different Python version than my default Python version. This is correct. However, when I check python path within the activated environment.

import sys
from pprint import pprint
pprint(sys.path)

I can see that the first 4 items are pointing to the default Python installation.

['', 'C:\\Python27\\Lib\\site-packages\\distribute-0.6.35-py2.7.egg', 'C:\\Python27\\Lib\\site-packages\\ipython-1.0.0-py2.7.egg', 'C:\\Python27\\Lib\\site-packages', 'C:\\Python27\\Lib\\site-packages\\setuptools-0.6c11-py2.7.egg-info', 'C:\\Users\\sennn\\AppData\\Local\\Continuum\\Anaconda32\\envs\\apiapi\\python27.zip', 'C:\\Users\\sennn\\AppData\\Local\\Continuum\\Anaconda32\\envs\\apiapi\\DLLs', 'C:\\Users\\sennn\\AppData\\Local\\Continuum\\Anaconda32\\envs\\apiapi\\lib', 'C:\\Users\\sennn\\AppData\\Local\\Continuum\\Anaconda32\\envs\\apiapi\\lib\\plat-win', 'C:\\Users\\sennn\\AppData\\Local\\Continuum\\Anaconda32\\envs\\apiapi\\lib\\lib-tk', 'C:\\Users\\sennn\\AppData\\Local\\Continuum\\Anaconda32\\envs\\apiapi', 'C:\\Users\\sennn\\AppData\\Local\\Continuum\\Anaconda32\\envs\\apiapi\\lib\\site-packages', 'C:\\Users\\sennn\\AppData\\Local\\Continuum\\Anaconda32\\envs\\apiapi\\lib\\site-packages\\PIL', 'C:\\Users\\sennn\\AppData\\Local\\Continuum\\Anaconda32\\envs\\apiapi\\lib\\site-packages\\Sphinx-1.2.3-py2.7.eg g', 'C:\\Users\\sennn\\AppData\\Local\\Continuum\\Anaconda32\\envs\\apiapi\\lib\\site-packages\\win32', 'C:\\Users\\sennn\\AppData\\Local\\Continuum\\Anaconda32\\envs\\apiapi\\lib\\site-packages\\win32\\lib', 'C:\\Users\\sennn\\AppData\\Local\\Continuum\\Anaconda32\\envs\\apiapi\\lib\\site-packages\\Pythonwin', 'C:\\Users\\sennn\\AppData\\Local\\Continuum\\Anaconda32\\envs\\apiapi\\lib\\site-packages\\runipy-0.1.1-py2.7.eg g', 'C:\\Users\\sennn\\AppData\\Local\\Continuum\\Anaconda32\\envs\\apiapi\\lib\\site-packages\\setuptools-5.8-py2.7. egg']

This creates a problem of importing wrong versions of some of libraries.

Why these default directories have been added to the path? Is this a default behavior when creating a new Anaconda environment? Is there any way to overwrite it?

like image 378
LLaP Avatar asked Sep 28 '22 20:09

LLaP


1 Answers

Check to see if you have the environment variables PYTHONPATH or PYTHONHOME set. conda info -a will also show you all the relevant environment variables that might cause this sort of thing to happen.

like image 153
asmeurer Avatar answered Oct 06 '22 18:10

asmeurer