为何无法在Visual Studio Code中选择全部已安装Python环境?Python3.7未显示
Hey Jordan, let's work through this issue—missing Python environments in VS Code is a pretty common hiccup, and we can sort it out with a few straightforward steps:
Why Your Python 3.7 Isn't Showing Up
VS Code relies on system environment variables, extension detection logic, and sometimes Conda's priority settings to find Python interpreters. If your manual 3.7 install isn't listed, it's likely one of these factors is blocking detection.
Step-by-Step Solutions
1. Manually Add the Python 3.7 Interpreter
This is the fastest way to get your 3.7 environment visible:
- Open VS Code and press
Ctrl+Shift+P(Windows) /Cmd+Shift+P(Mac) to open the command palette. - Type
Python: Select Interpreterand hit Enter. - Choose the
Enter interpreter path...option, then browse toC:\Python\Python3.7\python.exeand select it. Your 3.7 environment will now appear in the interpreter list.
2. Verify System PATH Environment Variables
VS Code often uses your system's PATH to find Python installations. Make sure your 3.7 path is included:
- Right-click "This PC" → Properties → Advanced System Settings → Environment Variables.
- Under System Variables, find the
Pathentry, click Edit, and add these two paths:C:\Python\Python3.7\C:\Python\Python3.7\Scripts\
- Save changes and restart VS Code (or your entire computer, if needed). VS Code should now auto-detect your 3.7 environment.
3. Adjust Conda Detection Settings
If Conda is prioritized over your manual installs, tweak these VS Code settings:
- Open VS Code settings with
Ctrl+,(Windows) /Cmd+,(Mac). - Option A: Add your manual Python paths to the environment detection list:
- Search for
python.environmentPath, then add your paths to the array:"python.environmentPath": ["C:\\Python\\Python2.7", "C:\\Python\\Python3.7"]
- Search for
- Option B: Disable Conda auto-detection (if you don't need it):
- Search for
python.condaEnabledand set it tofalse, then restart VS Code.
- Search for
4. Reload the Python Extension
Sometimes extension caching causes detection issues:
- Open the command palette (
Ctrl+Shift+P/Cmd+Shift+P), typeExtensions: Reload Window, and hit Enter. Once the window reloads, check the interpreter list again.
5. Validate Your Python 3.7 Installation
If none of the above works, confirm your 3.7 install is functional:
- Open Command Prompt (CMD) and run
py -3.7orC:\Python\Python3.7\python.exe. If this fails to launch the Python 3.7 shell, your installation might be corrupted. Reinstall Python 3.7 and make sure to check the Add Python to PATH box during setup.
内容的提问来源于stack exchange,提问作者Jordan Stefanelli

