Comments (12)
@antshar this seems like an issue with python itself. I don't see any of the extension python code on stack at all.
Try this in a terminal and see if that runs for you. We set PYTHONUTF8=1
before starting the server script, so you might have to do the same.
> cd <dir with non-latin char>
> set PYTHONUTF8=1
> <python3.10 path> <some_script.py>
from vscode-autopep8.
I tried the proposed steps and yes, set PYTHONUTF8=1
reproduces the very same error indeed. Moreover, even if a path doesn't contain non-latin character, the error still shows up. I tried C:\test\foo.py
.
Can it be related to the fact, my window's language is cyrillc based? Is there any way I can fix the issue (I'm ok with any possible workaround)?
from vscode-autopep8.
@antshar Does it run fine without the PYTHONUTF8=1
? You can unset it by using this command set PYTHONUTF8=
. Can you share your environment variables? I would particularly like to see the language env variables.
from vscode-autopep8.
Unsetting PYTHONUTF8
makes C:\test\foo.py
to run perfectly, but I don't know how to unset it for autopep8
.
Here are all env variables I get https://pastebin.com/y2g9HEzg (I don't see any language variables here, though)
from vscode-autopep8.
I've just noticed that the following
> cd C:\test
> set PYTHONUTF8=1
> python foo.py
leads to an error only when running from cmd.exe
while in powershell and git bash, set PYTHONUTF8=1
doesn't cause the exception.
from vscode-autopep8.
@antshar also can you launch the python in PowerShell (where it works) and run the following commands:
Can you also share how you installed the python? from windows store or python.org etc?
from vscode-autopep8.
I'm pretty sure I installed python from python.org
from vscode-autopep8.
I have asked someone with more experience in this area for input on this issue. Meanwhile I think you need to ask this on python.org. Since this is related to running Python itself and not really limited to the extension.
from vscode-autopep8.
Yes yes, I think the issue can be closed as not related to extension. Thank you for helping me find the cause in the first place, I appreciate that.
While I'll be finding a solution to this, I removed "PYTHONUTF8": "1"
everywhere in sources HOME\.vscode\extensions\ms-python.autopep8-2024.0.0
as a dirty fix, so I can use the extension.
from vscode-autopep8.
@antshar i heard back from someone. You might have a .pth
file somewhere that I has the character that might be causing this.
from vscode-autopep8.
I made a search with Everything which found ten-ish .pth
files, mostly in %PYTHONPATH%
. I checked each of them and yes, there was a single one that contained non-latin characters. It was easy-install.pth
with a single line — path to jupyterlab_sublime-master
.
Once I removed it, everything started to work with PYTHONUTF8=1
. That's an impressive guess with .pth
files! I must admit I spent a couple of hours trying to find a solution, but I found nothing even close to this.
I'm really grateful for your help, especially because it went far beyond autopep8
scope, so you could just say "unrelated".
from vscode-autopep8.
That's an impressive guess with
.pth
files!
Allow me to spoil the magic 😄 Open the file from the second last line of your traceback and look around the for
loop that broke:
File "c:\Users\antshar\AppData\Local\Programs\Python\Python310\lib\site.py", line 387, in addsitepackages
addsitedir(sitedir, known_paths)
File "c:\Users\antshar\AppData\Local\Programs\Python\Python310\lib\site.py", line 226, in addsitedir
addpackage(sitedir, name, known_paths)
File "c:\Users\antshar\AppData\Local\Programs\Python\Python310\lib\site.py", line 179, in addpackage
for n, line in enumerate(f):
File "c:\Users\antshar\AppData\Local\Programs\Python\Python310\lib\codecs.py", line 322, in decode
from vscode-autopep8.
Related Issues (20)
- 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
- 使用字符串格式化时代码格式错误导致功能异常 HOT 5
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.