【问题标题】:VS Code python extension recently started complaining about a Path error on Win10VS Code python 扩展最近开始抱怨 Win10 上出现路径错误
【发布时间】:2018-06-22 13:56:01
【问题描述】:

当我使用 python 文件启动 Visual Studio Code 时,我开始收到以下错误

The environment variable 'Path' seems to have 
some paths containing characters (';', '"' or ';;'). 
The existence of such characters are known to have 
caused the Python extension to not load. If the 
extension fails to load please modify your paths to 
remove these characters.

我检查了我的路径,确实有一个 ;; 出现了。我删除了它,但我仍然收到错误。

这是我当前的路径。

PATH=C:\ProgramData\Oracle\Java\javapath;C:\Program Files (x86)\Intel\iCLS Client\;C:\Program Files\Intel\iCLS Client\;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\Program Files\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files (x86)\Common Files\Lenovo;C:\SWTOOLS\ReadyApps;C:\Program Files\Calibre2\;c:\Program Files (x86)\Microsoft SQL Server\100\Tools\Binn\;c:\Program Files (x86)\Microsoft SQL Server\100\DTS\Binn\;C:\Program Files (x86)\Skype\Phone\;C:\Program Files\IDM Computer Solutions\UltraEdit;C:\Users\Dave\.dnx\bin;C:\Program Files\Microsoft DNX\Dnvm\;C:\Program Files\Git\cmd;C:\WINDOWS\System32\OpenSSH\;C:\Program Files\Intel\WiFi\bin\;C:\Program Files\Common Files\Intel\WirelessCommon\;C:\Program Files (x86)\Sophos\Sophos SSL VPN Client\bin;C:\Users\Dave\AppData\Local\atom\bin;C:\Users\Dave\AppData\Local\Microsoft\WindowsApps;C:\sqlite;C:\Python36\Scripts;C:\Program Files\Microsoft VS Code\bin;C:\Python36;

【问题讨论】:

标签: python windows path visual-studio-code


【解决方案1】:

您的本地 PATH 按此顺序包含以下文件夹路径:

C:\ProgramData\Oracle\Java\javapath
C:\Program Files (x86)\Intel\iCLS Client\
C:\Program Files\Intel\iCLS Client\
C:\WINDOWS\system32
C:\WINDOWS
C:\WINDOWS\System32\Wbem
C:\WINDOWS\System32\WindowsPowerShell\v1.0\
C:\Program Files\Intel\Intel(R) Management Engine Components\DAL
C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL
C:\Program Files\Intel\Intel(R) Management Engine Components\IPT
C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\IPT
C:\Program Files (x86)\Common Files\Lenovo
C:\SWTOOLS\ReadyApps
C:\Program Files\Calibre2\
c:\Program Files (x86)\Microsoft SQL Server\100\Tools\Binn\
c:\Program Files (x86)\Microsoft SQL Server\100\DTS\Binn\
C:\Program Files (x86)\Skype\Phone\
C:\Program Files\IDM Computer Solutions\UltraEdit
C:\Users\Dave\.dnx\bin
C:\Program Files\Microsoft DNX\Dnvm\
C:\Program Files\Git\cmd
C:\WINDOWS\System32\OpenSSH\
C:\Program Files\Intel\WiFi\bin\
C:\Program Files\Common Files\Intel\WirelessCommon\
C:\Program Files (x86)\Sophos\Sophos SSL VPN Client\bin
C:\Users\Dave\AppData\Local\atom\bin
C:\Users\Dave\AppData\Local\Microsoft\WindowsApps
C:\sqlite
C:\Python36\Scripts
C:\Program Files\Microsoft VS Code\bin
C:\Python36

所以在 local PATH 中没有包含被双引号括起来的文件夹路径,也没有包含分号的路径,也没有两个分号。

PATH 中的文件夹路径不应以反斜杠结尾。这是可能的,Microsoft 自己默认将带有尾随反斜杠的 PowerShell 文件夹路径添加到 system PATH。但我建议在 Windows 系统控制面板的高级系统设置中修复它。

system PATHuser PATH 的最后一个文件夹路径后不应有分号。一些编码不好的应用程序或脚本将文件夹路径附加到 local PATH 开头始终以分号开头,而不首先检查 PATH 是否已经以分号结尾。这导致 local PATH 最终包含 ;;。出于这个原因,C:\Python36 之后的分号应该被删除。

systemPATH 中的前四个文件夹路径应始终为:

%SystemRoot%\system32
%SystemRoot%
%SystemRoot%\System32\Wbem
%SystemRoot%\System32\WindowsPowerShell\v1.0

这意味着 系统 PATH 显示在环境变量对话框中并存储在 Windows 注册表中应始终以:

%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SystemRoot%\System32\WindowsPowerShell\v1.0

一些编码不好的安装程序会在最重要的文件夹路径(Windows 系统文件夹)之前插入文件夹路径。你也应该解决这个问题。

我想问题是由;C:\Python36 之后使用仅包含命令行的批处理文件引起的:

set "PATH=%PATH%;C:\Folder Path"

或者批处理文件包含命令行:

set PATH="%PATH%;C:\Folder Path"

该命令行损坏了 local PATH 环境变量,因为将分号分隔的文件夹路径列表更改为一个无效的文件夹路径。

另见:

【讨论】:

    【解决方案2】:

    对我来说,它只是 Python 路径末尾的 \

    C:\Users\ME\AppData\Local\Programs\Python\Python37\Scripts\
    

    在我删除最后一个\ 的那一刻,警告消失了!

    【讨论】:

      【解决方案3】:

      我遇到了这个问题,但我不知道该怎么做: 环境变量 'Path' 似乎有一些包含 '"' 字符的路径。已知此类字符的存在导致 Python 扩展无法加载。如果扩展无法加载,请修改您的路径以删除此 ' "' 字符。

      【讨论】:

        【解决方案4】:

        我遇到了问题,刚刚卸载了 VS 中的所有扩展并再次安装,然后就可以正常工作了。

        【讨论】:

          【解决方案5】:

          使用命令 CTRL +P 检查 Visual Studio 中的 INTERPRETER,如果您在 enter image description hereCONDA 环境中,请选择正确的 PATH 选择它

          【讨论】:

            【解决方案6】:

            错误以某种方式纠正,只需重新安装插件。它不会再次显示路径错误。

            【讨论】:

            • 您的答案可以通过额外的支持信息得到改进。请edit 添加更多详细信息,例如引用或文档,以便其他人可以确认您的答案是正确的。你可以找到更多关于如何写好答案的信息in the help center
            猜你喜欢
            • 1970-01-01
            • 2017-01-26
            • 2022-12-19
            • 2023-03-05
            • 1970-01-01
            • 2014-09-20
            • 2021-01-16
            • 1970-01-01
            • 2016-08-31
            相关资源
            最近更新 更多