簡體   English   中英

VSCode Python 調試與解釋器的路徑不同

[英]VSCode Python debugging doesn't have same PATH as interpreter

本質上,使用調試器似乎並沒有在集成終端加載 my.zshrc 時加載。 即這個簡單的測試在我調試時輸出不同的代碼。當我在終端中調用 pytest 時:

class TestPath(unittest.TestCase):

    def test_path(self):
        import os
        print(os.environ['PATH'])

這對我來說是個問題,因為我使用shutil.which(...)來查找可執行文件。 我知道它找到了正確的 Python 因為sys.version在調試器 REPL 和通過終端中產生相同的結果。

我什至在我的 settings.json 中添加了以下塊,這是我以前從未明確指向正確的 shell 的:

    "terminal.integrated.profiles.linux": {
      "zsh (login)": {
        "path": "/usr/bin/zsh",
        "args": ["-l"]
      }
    },
    "terminal.integrated.defaultProfile.linux": "zsh",
    "terminal.integrated.automationShell.linux": "/usr/bin/zsh",

直到最近這才成為問題,自 VSCode 1.62 以來我遇到了很多與調試相關的問題。 我已經降級了兩次,甚至設置"update.mode": "none" ,但比爾似乎一直在入侵並強迫我升級。

任何見解表示贊賞!

謝謝

您能否嘗試更新Python Extension 有些人遇到過類似的問題,你可以看看這個鏈接

暫無
暫無

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

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