Code Monkey home page Code Monkey logo

Comments (12)

karthiknadig avatar karthiknadig commented on June 3, 2024

@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.

antshar avatar antshar commented on June 3, 2024

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.

karthiknadig avatar karthiknadig commented on June 3, 2024

@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.

antshar avatar antshar commented on June 3, 2024

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.

antshar avatar antshar commented on June 3, 2024

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.

karthiknadig avatar karthiknadig commented on June 3, 2024

@antshar also can you launch the python in PowerShell (where it works) and run the following commands:
image

Can you also share how you installed the python? from windows store or python.org etc?

from vscode-autopep8.

antshar avatar antshar commented on June 3, 2024

image

I'm pretty sure I installed python from python.org

from vscode-autopep8.

karthiknadig avatar karthiknadig commented on June 3, 2024

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.

antshar avatar antshar commented on June 3, 2024

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.

karthiknadig avatar karthiknadig commented on June 3, 2024

@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.

antshar avatar antshar commented on June 3, 2024

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.

zooba avatar zooba commented on June 3, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.