10👍
You will receive this prompt if
- You have
"formatOnSave"
turned on as a setting - You selected autopep8 as your formatter
- The Python extension can’t find autopep8
So the options are:
- Turn off formatting on save
- Make sure you successfully installed autopep8 into your environment or you specified the path to autopep8 in your settings
My guess is there’s an installation failure because you are using a globally installed interpreter and you’re not allowed to install where pip wants to put autopep8.
- [Django]-Naming convention for Django URL, templates, models and views
- [Django]-Stack trace from manage.py runserver not appearing
- [Django]-Django: Use of DATE_FORMAT, DATETIME_FORMAT, TIME_FORMAT in settings.py?
4👍
I have also encountered this problem in my computer with Ubuntu 18.04. It turns out that the python extension need some settings. My solution is:
- Go to Python extension’s extension setting.
- Find Python>Formatting:Autopep8 Path term
- Add the full path of the autopep8 that you have installed.
- [Django]-How to get an ImageField URL within a template?
- [Django]-Django custom field validator vs. clean
- [Django]-Suddenly when running tests I get "TypeError: 'NoneType' object is not iterable
3👍
pip install pep8
pip install --upgrade autopep8
or
"python.formatting.provider": "autopep8"
- [Django]-What does 'many = True' do in Django Rest FrameWork?
- [Django]-Django limit_choices_to for multiple fields with "or" condition
- [Django]-How to add a cancel button to DeleteView in django
1👍
Adding this in for anyone who has this issue running WSL on Windows. You need to either need to be connected to Remote WSL in order to access pep8 in your WSL Python installation or install Python and pep8 on Windows since VS Code will be looking on Windows. No matter how magnificently installed autopep8
may be in WSL, VS Code won’t find it.
So my full solution was:
- If you don’t have Python installed in Windows, do that (dare I suggest you can even get it in the Microsoft Store!)
- Install
autopep8
in your Windows Python instance. e.g., from Command Prompt:python3 -m pip install autopep8
- Follow the instructions in any of the other responses if you’re still having issues.
- [Django]-Trying to migrate in Django 1.9 — strange SQL error "django.db.utils.OperationalError: near ")": syntax error"
- [Django]-Django REST Framework : "This field is required." with required=False and unique_together
- [Django]-Django rest framework: query parameters in detail_route
1👍
The easiest way to work with autopep8 in VSCode to follow the steps:
- install autopep8 via
pip install autopep8
into the desired virtual env - Open VSCode and press
ctrl + ,
which will open the settings - Search for
formatter
- Select
Python-autopep8
inEditor: Default Formatter
- One can also tick the
Editor: Format On Save
if he/she wishes to - Most importantly, open any .py file in that directory via VSCode and check at the bottom right of the of the VSCode window. Make sure that it is showing the venv name where the autopep8 has been installed and configured.
- [Django]-How to use pdb.set_trace() in a Django unittest?
- [Django]-AccessDenied when calling the CreateMultipartUpload operation in Django using django-storages and boto3
- [Django]-Django, Models & Forms: replace "This field is required" message
0👍
Install autopep from your terminal by running the following command
python -m pip install autopep8
That should solve the error 2 in vscode of no such file or directory error
- [Django]-Django middleware difference between process_request and process_view
- [Django]-A field with precision 10, scale 2 must round to an absolute value less than 10^8
- [Django]-ForeignKey to abstract class (generic relations)