编辑settings.json后无法在VScode中运行python

问题描述 投票:0回答:1
$ where python
C:\Users\Idan\AppData\Local\Programs\Python\Python38\python.exe
C:\Users\Idan\AppData\Local\Microsoft\WindowsApps\python.exe

错误:

Idan@DESKTOP-A16D3QA MINGW64 ~/Desktop/ttt
$ C:\Users\Idan\AppData\Local\Programs\Python\Python38\python.exe -u "c:\Users\Idan\AppData\Local\Programs\Python\Python38\s.py"
bash: C:UsersIdanAppDataLocalProgramsPythonPython38python.exe: command not found

默认设置json文件:

// Path to the pipenv executable to use for activation.
"python.pipenvPath": "pipenv",

// Path to the poetry executable.
"python.poetryPath": "poetry",

// Path to Python, you can use a custom version of Python by modifying this setting to include the full path.
"python.pythonPath": "python",

settings.json

我尝试做的事情(集成pipenv而不是venv):

"python.pythonPath": "C:\\Users\\Idan\\AppData\\Local\\Programs\\Python\\Python38\\python.exe",
    "python.pipenvPath": "pipenv",
    "python.testing.pytestEnabled": true,
    "python.venvPath": "C:\\Users\\Idan\\.virtualenvs",

    ],
    "code-runner.executorMap": {
        "python": "$pythonPath -u $fullFileName"
    },
    "terminal.integrated.shell.windows": "C:\\Program Files\\Git\\bin\\bash.exe",

我尝试过的其他配置导致相同的错误

 "python.venvPath": "C:\\Users\\Idan\\.virtualenvs",
    // this is the actual locatation
    // of the pythonpath C:\\Users\\Idan\\.virtualenvs\\Idan-iyfIpKqV\Scripts\python.exe
    "python.pythonPath": "$venvPath\\pipenvPath\\Scripts\\python.exe",
    //"python.pythonPath": "$venvPath\\ENV-NAME\\Scripts\\python.exe",

这是完整的settings.json,我有:https://gist.github.com/IdanBanani/0d562770f14f3098debb6e1d47179e3f

以前,将这两个来源的行合并起来是可行的(venv):https://github.com/CoreyMSchafer/dotfiles/blob/master/settings/VSCode-Settings.jsonhttps://github.com/xames3/xai_django/blob/bcaf169837d484d0bcf8686c18dc0529d1469034/.vscode/settings.json

但是我尝试替换为pipenv,并且将来可能会尝试将其自动设置为创建并激活virtualenv(pipenv安装,pipenv外壳),但不确定它有多容易]

也:由于输出控制台中的错误消息,我不得不从.bashrc文件中删除thefuck项目的这些行(也许安装/ pip软件包已被删除)

eval $(thefuck --alias)
# You can use whatever you want as an alias, like for Mondays:
eval $(thefuck --alias FUCK)
python visual-studio-code virtualenv vscode-settings pipenv
1个回答
0
投票

这是我当前的解决方法,但对于一般情况,我认为它不够好

为什么它会继续在恒定的文件夹名称Idan-iyfIpKqV中创建虚拟环境?

 "python.venvPath": "C:/Users/Idan/.virtualenvs",
 "python.pythonPath": "C:/Users/Idan/.virtualenvs/Idan-iyfIpKqV/Scripts/python.exe",
© www.soinside.com 2019 - 2024. All rights reserved.