簡體   English   中英

IntelliSense 不適用於 Visual Studio Code/嵌入式 python

[英]IntelliSense not working with Visual Studio Code/embeddable python

我想在 Windows 10 環境中使用 python (3.7.0) 的可嵌入版本,而無需安裝程序/管理員權限。 Visual Studio Code 是要使用上述 python 解釋器進行配置的 IDE。

要安裝可嵌入的 python,我遵循了這個答案和這個問題的說明,它在 CLI 上運行良好。

根據此站點設置 VS Code:

  • 安裝了Python 擴展和 linter
  • 在 PATH 環境中添加了我的 python 文件夾( python.exe根目錄)和子文件夾\\ScriptsC:/my/path/to/PythonC:/my/path/to/Python/Scripts
  • 在用戶設置中這樣配置解釋器: python.pythonPath": "C:/my/path/to/Python/python.exe

示例腳本:

msg = "Hello World"
print(msg)

在 VS Code 中,我可以通過右鍵單擊活動編輯器->“在終端中運行 Python 文件”來執行腳本。

但我沒有得到智能感知:

在此處輸入圖片說明

當我打印sys.path ,它給了我

C:\my\path\to\Python\python37.zip
C:\my\path\to\Python\
C:\my\path\to\Python\lib\site-packages

Python 擴展的文檔沒有說明不支持可嵌入的 Python:

安裝一個 Python 3 版本(本教程就是為此編寫的)。 選項包括:

(所有操作系統)從 python.org 下載; 通常使用頁面上最先出現的下載 Python 3.6.5 按鈕(或任何最新版本)。

...

任何想法如何解決這個問題?

我使用的是 Anaconda 的 Python 版本,但我也無法讓 Intellisense 顯示任何內容,類似於您所描述的內容。

最后,我讓 Python 智能感知開始在 VS Code 中工作的方式是:

  1. 打開終端(查看菜單 => 終端)
  2. 輸入conda init powershell
  3. 重新啟動 VS 代碼

之后,Python 智能感知開始正常工作。

我遇到了同樣的 IntelliSense 無法工作的問題 - 當使用 ctrl + 空格主動請求自動完成時,沒有顯示任何內容和“正在加載...”。

我使用的是 VSCode 1.25.1、可嵌入的 Python 3.8.6 和 Python 擴展 2018.7.1

簡而言之,Python 擴展 2018.7.1 不支持 python 3.8

雖然 IntelliSense 在 VSCode 上靜默失敗,打開“幫助”>“切換開發者工具”>“控制台”,我遇到了以下錯誤:

Python Extension: stderr jediProxy, Error (stderr) Traceback (most recent call last):
  File "d:\Users\user\.vscode\extensions\ms-python.python-2018.7.1\pythonFiles\parso\grammar.py", line 236, in load_grammar
    return _loaded_grammars[path]
KeyError: 'd:\\Users\\user\\.vscode\\extensions\\ms-python.python-2018.7.1\\pythonFiles\\parso\\python\\grammar38.txt'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "d:\Users\user\.vscode\extensions\ms-python.python-2018.7.1\pythonFiles\parso\grammar.py", line 239, in load_grammar
    with open(path) as f:
FileNotFoundError: [Errno 2] No such file or directory: 'd:\\Users\\user\\.vscode\\extensions\\ms-python.python-2018.7.1\\pythonFiles\\parso\\python\\grammar38.txt'

制作grammar38.txt的副本grammar37.txt是不足以解決智能感知在這種情況下-在一定程度上。 如果可能,降級python或升級vscode會更好。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM