Comments (9)
@john1997x Can you run the command from the terminal? This looks like an issue with autopep8 itself or the encoding used to save the file (the file should be saved as UTF-8).
> set PYTHONPATH=c:\Users\joaop.vscode\extensions\ms-python.autopep8-2023.2.0\bundled\libs
> type <python-file-to-format> | c:\Users\joaop.pyenv\pyenv-win\versions\3.7.9\python.exe -m autopep8 --max-line-length=250 -
Make sure to include the -
at the end in the second command.
from vscode-autopep8.
similar problem when autopep8 formatting
log:
2023-05-25 11:16:33.900 [info] [Trace - 上午11:16:33] Received response 'textDocument/formatting - (2)' in 354ms.
2023-05-25 11:16:37.022 [info] [Trace - 上午11:16:37] Sending request 'textDocument/formatting - (3)'.
2023-05-25 11:16:37.027 [info] [Trace - 上午11:16:37] Received notification 'window/logMessage'.
2023-05-25 11:16:37.027 [info] c:\Users\jhele\AppData\Local\Programs\Python\Python310\python.exe -m autopep8 -
2023-05-25 11:16:37.027 [info] [Trace - 上午11:16:37] Received notification 'window/logMessage'.
2023-05-25 11:16:37.027 [info] CWD Server: c:\Users\jhele\Desktop\p2p_orm
2023-05-25 11:16:37.290 [info] [Trace - 上午11:16:37] Received notification 'window/logMessage'.
2023-05-25 11:16:37.290 [info] Traceback (most recent call last):
File "c:\Users\jhele\AppData\Local\Programs\Python\Python310\lib\runpy.py", line 196, in _run_module_as_main
return _run_code(code, main_globals, None,
File "c:\Users\jhele\AppData\Local\Programs\Python\Python310\lib\runpy.py", line 86, in _run_code
exec(code, run_globals)
File "c:\Users\jhele.vscode\extensions\ms-python.autopep8-2023.4.0\bundled\libs\autopep8.py", line 4570, in
sys.exit(main())
File "c:\Users\jhele.vscode\extensions\ms-python.autopep8-2023.4.0\bundled\libs\autopep8.py", line 4516, in main
wrap_output(sys.stdout, encoding=encoding).write(fixed_stdin)
UnicodeEncodeError: 'cp950' codec can't encode character '\udc93' in position 1638: illegal multibyte sequence
from vscode-autopep8.
Me too
I can use autopep8 without error in the terminal.
log:
2023-05-25 21:08:10.614 [info] [Trace - 21:08:10] Sending request 'textDocument/formatting - (6)'.
2023-05-25 21:08:10.620 [info] [Trace - 21:08:10] Received notification 'window/logMessage'.
2023-05-25 21:08:10.621 [info] d:\vscode\Pyside6\qt_env\Scripts\python.exe -m autopep8 -
2023-05-25 21:08:10.621 [info] [Trace - 21:08:10] Received notification 'window/logMessage'.
2023-05-25 21:08:10.622 [info] CWD Server: d:\vscode\Pyside6
2023-05-25 21:08:11.022 [info] [Trace - 21:08:11] Received notification 'window/logMessage'.
2023-05-25 21:08:11.022 [info] Traceback (most recent call last):
File "", line 198, in _run_module_as_main
File "", line 88, in _run_code
File "d:\vscode\Pyside6\qt_env\Lib\site-packages\autopep8.py", line 4570, in
sys.exit(main())
^^^^^^
File "d:\vscode\Pyside6\qt_env\Lib\site-packages\autopep8.py", line 4516, in main
wrap_output(sys.stdout, encoding=encoding).write(fixed_stdin)
UnicodeEncodeError: 'gbk' codec can't encode character '\udcad' in position 303: illegal multibyte sequence
2023-05-25 21:08:11.022 [info] [Trace - 21:08:11] Received response 'textDocument/formatting - (6)' in 409ms.
from vscode-autopep8.
If I remove all the code with Chinese, I won't get this error.
from vscode-autopep8.
@Usercyk Can you share your environment variables?
from vscode-autopep8.
@Usercyk Can you also confirm if the encoding for your python file is utf-8? You should be able to see the encoding on your status bar.
from vscode-autopep8.
set PYTHONPATH=c:\Users\joaop.vscode\extensions\ms-python.autopep8-2023.2.0\bundled\libs
Has the same error. File encoding - UTF-8. Python 3.11.4 autopep8 upgraded.
from vscode-autopep8.
The issue is caused by a bug in autopep8 itself. hhatto/autopep8#685
Identified this issue here #104
from vscode-autopep8.
give a way to avoid the case:
change VS setting "files.encoding": "gbk" as same as the OS default encode .
or change OS default encode to utf-8.
the reason is
C:\Users\admin.vscode\extensions\ms-python.autopep8-2023.4.0\bundled\libs\autopep8.py
line 4511 : read_stdin = sys.stdin.read()
using OS default encode to read your code steam , it will be decoding wrong.
from vscode-autopep8.
Related Issues (20)
- Message: KeyError: <function continued_indentation at 0x7f79d4bdc700> Code: -32602 HOT 1
- Running 'autopep8' Formatter running forever HOT 4
- Auto-formatting inside f-strings HOT 4
- Tabs are being expanded regardless of project configuration HOT 6
- Extension 'autopep8' is configured as formatter but it cannot format 'Pyton'-files HOT 3
- Semicolon in f-string becomes newline HOT 5
- Command 'Format Document With...' resulted in an error HOT 1
- Formatting not working HOT 7
- Cannot Format Selection HOT 1
- Format not working on file save HOT 2
- Writes configuration error into the target source code HOT 3
- It can work, but there are some doubts. HOT 1
- .pep8 file in subdirectories is not respected HOT 2
- Extension should format Python code regardless of the indent errors HOT 1
- [TRIAGE] Context Menu document formatting not addressing E501 line too long HOT 1
- what is the "Unknown Configuration Setting"? HOT 5
- Incorrectly formatting strings containing emojis HOT 3
- New Release HOT 1
- Incorrect pre-release versioning HOT 1
- Autopep8 argument didn't works HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from vscode-autopep8.