I wanted to set lint & formatting of python file with VScode.
If you search for python vscode lint
etc., you will get caught in articles like this and leave the following code as it is written in setting.json
. I copied it.
setting.json
"python.linting.enabled": true,
"python.linting.pylintEnabled": false,
"python.linting.flake8Enabled": true,
"python.linting.lintOnSave": true,
"python.formatting.provider": "autopep8",
"editor.formatOnSave": true
I was hoping that this would somehow run formatting when saving, and when I tried to save, VScode gave me the following warning.
Formatter autopep8 is not installed. Install?
So, just press Yes, try installing autopep8 globally with pip install autopep8
, or write ʻautopep8 in
pyproject.toml` of our project that uses Poetry as a package manager. However, the warning did not disappear and it was a little difficult because it was not shaped at the time of saving.
In my case, I solved it by adding the following code
setting.json
"python.formatting.autopep8Path": "/Users/USERNAME/.pyenv/shims/autopep8"
It seems that I needed to tell you the Path of ʻautopep8 that runs as formatting.provider. ʻAutopep8
Path can be output by the following procedure (if installed)
$ which autopep8
$ pyenv which autopep8 #This if you are using pyenv
https://github.com/microsoft/vscode-python/issues/6495 https://gist.github.com/Tinitto/8d9f9638ff54e0a8351e4ba2d8a37441