简体   繁体   中英

Visual Studio Code and PowerShell do not identify new Python version

On Windows 10, I want to use Python 3.8, which I installed and downloaded.

However, in Visual Studio Code, the cmd -environment, and PowerShell, the command python returns 3.5.6, an Anaconda install.

In particular, the screenshot shows that (at the bottom left) the active interpreter should be 3.8.1; and the "Python Path" in the settings also directs to the correct path, but typing python in Terminal just outputs 3.5.6.

VS 代码截图

In the PATH -variable, I deleted the line that points to 3.5.6's directory, and added the directory of 3.8.1 (was done automatically during the install):

在此处输入图片说明

What more do I need to do?


Edit 1

Environment Variables are:

Path: C:\\Users\\d91776\\AppData\\Local\\Programs\\Python\\Python38-32\\Scripts\\;C:\\Users\\d91776\\AppData\\Local\\Programs\\Python\\Python38-32\\;%USERPROFILE%\\AppData\\Local\\Microsoft\\WindowsApps;C:\\Program Files\\java\\jdk\\bin;C:\\Program Files\\Java\\jdk1.8.0_191\\bin;C:\\Program Files\\Java\\jre1.8.0_191\\bin;C:\\Users\\d91776\\AppData\\Local\\Programs\\Microsoft VS Code\\bin;C:\\Users\\d91776\\Desktop\\Selenium Markitwire\\geckodriver-v0.24.0-win64;C:\\Users\\d91776\\AppData\\Local\\Google\\Cloud SDK\\google-cloud-sdk\\bin;

PSModulePath: %HomeDrive%%HomePath%\\Documents\\WindowsPowerShell\\Modules;C:\\Users\\d91776\\AppData\\Local\\Google\\Cloud SDK\\google-cloud-sdk\\platform\\PowerShell

TEMP and TMP: are both %USERPROFILE%\\AppData\\Local\\Temp

There is another "Path" in System variables, but I cannot display it as text. But it does not seem to related to the python paths. See highlighted section in Screenshot:

在此处输入图片说明


Edit 2

In Anaconda, I deactivated the one additional environment that had Python version 3.5.6.

However, the problem now persists with Python version 3.7.3 (version of Python displayed upon typing python in terminal) and 3.8.1 (selected in VS Code as Python interpreter, and displayed in the bottom-left, just as in the above screenshot).

C:\>python
Python 3.7.3 (default, Mar 27 2019, 17:13:21) [MSC v.1915 64 bit (AMD64)] :: Anaconda, Inc. on win32

Warning:
This Python interpreter is in a conda environment, but the environment has
not been activated.  Libraries may fail to load.  To activate this environment
please see https://conda.io/activation

Type "help", "copyright", "credits" or "license" for more information.

The Python extension for VS Code does not influence what the python command points at; that comes down to your PATH environment variable. If you want to manually launch Python 3.8 then you should run python3.8 or py -3.8 (if you just want the newest Python 3 installed then change that to python3 or py -3 ). Otherwise create a virtual environment with Python 3.8 and when it's activated python will be Python 3.8.

As for why this doesn't work in PowerShell, it's possible the install of Python 3.8 that you used installed a python command for Python 3.8 (you would have to check those directories on your PATH to verify this).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM