Repository navigation
Unable to access Python 3 environments in /anaconda2 #7548
Description
Issue Type: Bug
When I try to select a Python interpreter, only the Python 2 environments are appearing. I created a python 3 environment in anaconda but it is not showing up as a Python interpreter in VSCode.
When I look at my conda environments, I see:
$ conda env list
# conda environments:
#
base /anaconda2
python3 * /anaconda2/envs/python3
sk /anaconda2/envs/sk
But when I try to select an interpreter only base, sk, and other (non conda) interpreters appear. I went into my settings.json and added:
{
"python.pythonPath": "/anaconda2/envs/python3",
"python.condaPath": "/anaconda2/envs/python3"
}
but the bottom left still says "Select Python Interpreter" and I cannot run the code. Restarting it did not help. Note that outside of VSCode I can run the python 3 environment and it works.
Here is the output of conda info --json
{
"GID": 20,
"UID": 501,
"active_prefix": "/anaconda2/envs/python3",
"active_prefix_name": "python3",
"channels": [
"https://repo.anaconda.com/pkgs/main/osx-64",
"https://repo.anaconda.com/pkgs/main/noarch",
"https://repo.anaconda.com/pkgs/r/osx-64",
"https://repo.anaconda.com/pkgs/r/noarch"
],
"conda_build_version": "3.18.9",
"conda_env_version": "4.7.11",
"conda_location": "/anaconda2/lib/python2.7/site-packages/conda",
"conda_prefix": "/anaconda2",
"conda_private": false,
"conda_shlvl": 2,
"conda_version": "4.7.11",
"config_files": [
"/Users/juliussimonelli/.condarc"
],
"default_prefix": "/anaconda2/envs/python3",
"env_vars": {
"CIO_TEST": "<not set>",
"CONDA_DEFAULT_ENV": "python3",
"CONDA_EXE": "/anaconda2/bin/conda",
"CONDA_PREFIX": "/anaconda2/envs/python3",
"CONDA_PREFIX_1": "/anaconda2",
"CONDA_PROMPT_MODIFIER": "(python3) ",
"CONDA_PYTHONBREAKPOINT": "",
"CONDA_PYTHON_EXE": "/anaconda2/bin/python",
"CONDA_ROOT": "/anaconda2",
"CONDA_SHLVL": "2",
"PATH": "/anaconda2/bin:/anaconda3/bin:/anaconda2/envs/python3/bin:/anaconda2/condabin:/Users/juliussimonelli/anaconda2/bin:/Users/juliussimonelli/bin:/usr/local/cuda/bin:/usr/local/bin:/usr/local/sbin:/usr/local/share/python:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/Users/juliussimonelli/.local/bin",
"PYTHONPATH": "/Library/Python/2.7/site-packages:/Users/juliussimonelli/orbital/base/core/oicv/src/py:/Users/juliussimonelli/orbital/base/core/chameleon_client/src/py:/Users/juliussimonelli/orbital/base/core/catalog_client/src/py:/Users/juliussimonelli/orbital/base/core/oil/src/py:/Users/juliussimonelli/orbital/base/core/retail/src/py:/Users/juliussimonelli/orbital/base/core/iqt:/Users/juliussimonelli/orbital/base/core/sandbox:/Users/juliussimonelli/orbital/base/core/services/src/py:/Users/juliussimonelli/orbital/base/core/projects:/Users/juliussimonelli/orbital/base/core/OFL/src/py::/Users/juliussimonelli/orbital/base/ops/tools/libs/python-common/",
"PYTHONUNBUFFERED": "1",
"REQUESTS_CA_BUNDLE": "<not set>",
"S3_ASTRIUM_REQUEST_PATH": "astrium/request",
"S3_CHINACON_INGESTION_PATH": "china",
"S3_IQT_INGESTION_PATH": "iqt",
"S3_OIL_INGESTION_PATH": "oil",
"S3_REQUEST_PATH": "aether/requests",
"S3_RETAIL_INGESTION_PATH": "retail",
"SSL_CERT_FILE": "<not set>"
},
"envs": [
"/anaconda2",
"/anaconda2/envs/python3",
"/anaconda2/envs/sk"
],
"envs_dirs": [
"/anaconda2/envs",
"/Users/juliussimonelli/.conda/envs"
],
"netrc_file": null,
"offline": false,
"pkgs_dirs": [
"/anaconda2/pkgs",
"/Users/juliussimonelli/.conda/pkgs"
],
"platform": "osx-64",
"python_version": "2.7.16.final.0",
"rc_path": "/Users/juliussimonelli/.condarc",
"requests_version": "2.21.0",
"root_prefix": "/anaconda2",
"root_writable": true,
"site_dirs": [
"~/.local/lib/python2.7"
],
"sys.executable": "/anaconda2/bin/python",
"sys.prefix": "/anaconda2",
"sys.version": "2.7.16 |Anaconda, Inc.| (default, Aug 22 2019, 10:59:10) \n[GCC 4.2.1 Compatible Clang 4.0.1 (tags/RELEASE_401/final)]",
"sys_rc_path": "/anaconda2/.condarc",
"user_agent": "conda/4.7.11 requests/2.21.0 CPython/2.7.16 Darwin/18.7.0 OSX/10.14.6",
"user_rc_path": "/Users/juliussimonelli/.condarc",
"virtual_pkgs": []
}
Extension version: 2019.9.34911
VS Code version: Code 1.38.1 (b37e54c98e1a74ba89e03073e5a3761284e3ffb0, 2019-09-11T13:31:32.854Z)
OS version: Darwin x64 18.7.0
Remote OS version: Linux x64 3.10.0-957.5.1.el7.x86_64
System Info
| Item | Value |
|---|---|
| CPUs | Intel(R) Core(TM) i7-8559U CPU @ 2.70GHz (8 x 2700) |
| GPU Status | 2d_canvas: enabled flash_3d: enabled flash_stage3d: enabled flash_stage3d_baseline: enabled gpu_compositing: enabled multiple_raster_threads: enabled_on native_gpu_memory_buffers: enabled oop_rasterization: disabled_off protected_video_decode: unavailable_off rasterization: enabled skia_deferred_display_list: disabled_off skia_renderer: disabled_off surface_synchronization: enabled_on video_decode: enabled viz_display_compositor: disabled_off webgl: enabled webgl2: enabled |
| Load (avg) | 3, 5, 5 |
| Memory (System) | 16.00GB (0.11GB free) |
| Process Argv | -psn_0_2728602 |
| Screen Reader | no |
| VM | 0% |
| Item | Value |
|---|---|
| Remote | SSH: localhost |
| OS | Linux x64 3.10.0-957.5.1.el7.x86_64 |
| CPUs | Intel(R) Xeon(R) CPU E5-2686 v4 @ 2.30GHz (4 x 2699) |
| Memory (System) | 59.81GB (3.36GB free) |
| VM | 0% |
Activity
ericsnowcurrently commentedon Sep 23, 2019
Julius (@juliussimonelli), thanks for letting us know about this. I'm going to take a look at this as soon as I can.
ericsnowcurrently commentedon Sep 25, 2019
The values you tried in your settings.json aren't quite right. Try using the following workspace settings:
{ "python.pythonPath": "/anaconda2/envs/python3/bin/python", "python.condaPath": "/anaconda2/bin/conda" }juliussimonelli commentedon Sep 25, 2019
I just updated it to your suggestion and it's still not working. Same error.
ericsnowcurrently commentedon Sep 25, 2019
Also, is the "python3" environment one using Python 3? If so then that's probably your problem. It looks like you're using Anaconda set up for Python 2. In particular, the
conda info --jsonoutput you provided shows (under "env_vars"):"PYTHONPATH": "/Library/Python/2.7/site-packages:.... That will cause problems under Python 3.juliussimonelli commentedon Sep 25, 2019
Yes, it is using Python 3. The actual conda environment works fine though. I can activate it and run Python 3 code on it with no problem.
juliussimonelli commentedon Sep 25, 2019
It has its own
site-packages:ericsnowcurrently commentedon Sep 25, 2019
When Python resolves imports, the first match under
sys.pathwins. In this case, anything found in/Library/Python/2.7/site-packageswill be used, which may not work under Python 3.It sounds like that isn't a problem for you, but it might impact how we invoke the interpreter when discovering the available interpreters.
What do you see in the "Python" output panel? We should see conda being invoked in various ways when looking for interpreters. For example, here's what I see (using miniconda, with several other system Pythons installed):
I'd like to see what is showing up for you. It may also be useful to see the "developer tools" output, from
Consoleunder theDeveloper Toolspanel (toggle Developer Tools on underHelp; turn on source maps to make any tracebacks be useful by runningEnable source map support for extension debugging)Note that (currently) when we invoke the interpreter from a particular conda environment, we run the executable directly, rather than using
conda run .... However, I'm not sure that's related. If it is then it's something we're already working on fixing.juliussimonelli commentedon Sep 25, 2019
Here's the output from the Python panel:
juliussimonelli commentedon Sep 25, 2019
Sorry, but I didn't fully follow the next part. I turned on developer tools and got the image below. I'm not clear where to run

Enable source map support for extension debuggingericsnowcurrently commentedon Sep 25, 2019
Thanks, that really helps. From the "Python" output panel the key point chronologically is the line that starts with
Diagnostic Code: InvalidPythonInterpreterDiagnostic, Message:. That corresponds with the traceback that you see in the developer console. The traceback implies that the "enum" module is bad, which makes me think that perhaps there is an enum module in/Library/Python/2.7/site-packages. Could you provide a directory listing for that directory?Also, what happens when you invoke the problematic script directly? Try the following (copied from the logs you provided):
juliussimonelli commentedon Sep 25, 2019
yep, it's an enum problem:
9 remaining items
juliussimonelli commentedon Sep 25, 2019
ericsnowcurrently commentedon Sep 25, 2019
Please get the logs again from the "Python" output panel and the developer console. Thanks!
juliussimonelli commentedon Sep 25, 2019
Here's the Python output panel:
juliussimonelli commentedon Sep 25, 2019
Here are the developer tools.

These were generated by starting a new VSCode window and checking that
/Library/Python/2.7/site-packagesisn't present (it wasn't).joobei commentedon Oct 1, 2019
I'm having the same problem in:
Version: 1.38.1
Commit: b37e54c98e1a74ba89e03073e5a3761284e3ffb0
Date: 2019-09-11T13:31:32.854Z
Electron: 4.2.10
Chrome: 69.0.3497.128
Node.js: 10.11.0
V8: 6.9.427.31-electron.0
OS: Darwin x64 18.7.0
The anaconda environment is perfectly accessible through command line but vscode, despite explicitly specifying python.pythonpath cannot find it. Here's the environment in question:
jubei$ conda info
active environment : mlagents
active env location : /Users/jubei/coding/anaconda3/envs/mlagents
shell level : 2
user config file : /Users/jubei/.condarc
populated config files : /Users/jubei/.condarc
conda version : 4.7.10
conda-build version : 3.18.8
python version : 3.7.3.final.0
virtual packages :
base environment : /Users/jubei/coding/anaconda3 (writable)
channel URLs : https://repo.anaconda.com/pkgs/main/osx-64
https://repo.anaconda.com/pkgs/main/noarch
https://repo.anaconda.com/pkgs/r/osx-64
https://repo.anaconda.com/pkgs/r/noarch
package cache : /Users/jubei/coding/anaconda3/pkgs
/Users/jubei/.conda/pkgs
envs directories : /Users/jubei/coding/anaconda3/envs
/Users/jubei/.conda/envs
platform : osx-64
user-agent : conda/4.7.10 requests/2.22.0 CPython/3.7.3 Darwin/18.7.0 OSX/10.14.6 UID:GID : 501:20
netrc file : None
offline mode : False
joobei commentedon Oct 7, 2019
In my case the problem was a broken anaconda installation. Different environments were in different subdirectories. I have since re-installed anaconda and the problem seems to be fixed but nevertheless, given an explicit path to the environment the python plugin should have been able to load it.
ericsnowcurrently commentedon Oct 30, 2019
Julius (@juliussimonelli), sorry for the long delay. Have you tried re-installing Anaconda?
Also, you mentioned that you were having the problem even though
/Library/Python/2.7/site-packageswas no longer present. Those logs from the developer tools console indicate the same problem (module 'enum' has no attribute 'IntFlag'). That implies that something is still broken with your PYTHONPATH.What does
/anaconda2/envs/python3/bin/python -c 'import enum; print(enum.__file__)'say now?juliussimonelli commentedon Nov 4, 2019
Right now I get:
although the environment might have changed since I first posted this. I should probably just reinstall Anaconda and see if that helps. I think last time I installed Anaconda2 and made python 3 environments, but this time I'll install Anaconda3 and make python2 environments.
ericsnowcurrently commentedon Nov 4, 2019
Julius (@juliussimonelli), sounds good. Please let us know if you see any problems under Anaconda3. Thanks!
brettcannon commentedon Jan 8, 2020
Because we have not heard back with the information we requested, we are closing this issue for now. If you are able to provide the info later on then we will be happy to re-open this issue to pick up where we left off.