How To Prevent Anaconda Environment From Reading Libraries Installed In Local
Python tries to read a library installed under ~/.local, even though I am working on an anaconda environment. > conda create -n testproj python=3.6 > conda activate testproj
Solution 1:
I get the same behavior on windows, clean environments include your user local packages. This is an open issue: https://github.com/conda/conda/issues/7173. conda
doesn't support doing what you're asking directly (yet).
You can always just set the environment variable PYTHONNOUSERSITE
(to any value), or invoke your interpreter with the -s
switch, and you wont get your local packages (~/.local
on windows is C:\Users\<username>\AppData\Roaming\Python\Python36\site-packages
):
(test-env) C:\Users\matt>python -m site
sys.path = [
'C:\\Users\\matt',
'C:\\Anaconda440\\envs\\test-env\\python36.zip',
'C:\\Anaconda440\\envs\\test-env\\DLLs',
'C:\\Anaconda440\\envs\\test-env\\lib',
'C:\\Anaconda440\\envs\\test-env',
'C:\\Users\\matt\\AppData\\Roaming\\Python\\Python36\\site-packages',
'C:\\Users\\matt\\AppData\\Roaming\\Python\\Python36\\site-packages\\some_lib-1.0-py3.6.egg',
'C:\\Anaconda440\\envs\\test-env\\lib\\site-packages',
]
USER_BASE: 'C:\\Users\\matt\\AppData\\Roaming\\Python' (exists)
USER_SITE: 'C:\\Users\\matt\\AppData\\Roaming\\Python\\Python36\\site-packages' (exists)
ENABLE_USER_SITE: True
versus (note the -s
switch, and now my local packages are no longer on my sys.path
):
(test-env) C:\Users\matt>python -s -m site
sys.path = [
'C:\\Users\\matt',
'C:\\Anaconda440\\envs\\test-env\\python36.zip',
'C:\\Anaconda440\\envs\\test-env\\DLLs',
'C:\\Anaconda440\\envs\\test-env\\lib',
'C:\\Anaconda440\\envs\\test-env',
'C:\\Anaconda440\\envs\\test-env\\lib\\site-packages',
]
USER_BASE: 'C:\\Users\\matt\\AppData\\Roaming\\Python' (exists)
USER_SITE: 'C:\\Users\\matt\\AppData\\Roaming\\Python\\Python36\\site-packages' (exists)
ENABLE_USER_SITE: False
HTH.
Post a Comment for "How To Prevent Anaconda Environment From Reading Libraries Installed In Local"