Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Setting a Path does not Work. #292

Closed
04Samir opened this issue Sep 3, 2024 · 1 comment
Closed

Setting a Path does not Work. #292

04Samir opened this issue Sep 3, 2024 · 1 comment
Labels
bug Issue identified by VS Code Team member as probable bug triage-needed

Comments

@04Samir
Copy link

04Samir commented Sep 3, 2024

Diagnostic Data

  • Python version (& distribution if applicable, e.g., Anaconda): 3.12.5
  • Type of virtual environment used (e.g., conda, venv, virtualenv, etc.): .venv
  • Operating system (and version): Windows 11
  • Version of tool extension you are using: v2024.0.0

Behaviour

Expected Behavior

If I installed autopep8 via pip, either in my .venv or globally in PATH, it should use that autopep8 version.

Actual Behavior

It uses the version that comes with the extension, v2.1.0.

Reproduction Steps:

Add the following in your workspace's .vscode/settings.json:

"autopep8.path": ["autopep8"]

Logs:

Click here for detailed logs
 2024-09-03 22:13:01.970 [info] No interpreter found from setting autopep8.interpreter
 2024-09-03 22:13:01.970 [info] Getting interpreter from ms-python.python extension for workspace <path-to-workspace>
 2024-09-03 22:13:01.973 [info] Interpreter from ms-python.python extension for <path-to-workspace>: <path-to-workspace>\.venv\Scripts\python.exe
 2024-09-03 22:13:01.973 [info] Server: Stop requested
 2024-09-03 22:13:01.973 [debug] Server State: Stopped
 2024-09-03 22:13:01.978 [info] No interpreter found from setting autopep8.interpreter
 2024-09-03 22:13:01.978 [info] Getting interpreter from ms-python.python extension for workspace <path-to-workspace>
 2024-09-03 22:13:01.979 [info] Interpreter from ms-python.python extension for <path-to-workspace>: <path-to-workspace>\.venv\Scripts\python.exe
 2024-09-03 22:13:01.981 [info] Server run command: <path-to-workspace>\.venv\Scripts\python.exe c:\Users\<user>\.vscode\extensions\ms-python.autopep8-2024.0.0\bundled\tool\lsp_server.py
 2024-09-03 22:13:01.982 [info] Server: Start requested.
 2024-09-03 22:13:01.982 [debug] Server State: Starting
 2024-09-03 22:13:02.663 [info] CWD Server: <path-to-workspace>
 2024-09-03 22:13:02.664 [info] sys.path used to run Server:
    c:\Users\<user>\.vscode\extensions\ms-python.autopep8-2024.0.0\bundled\libs
    c:\Users\<user>\.vscode\extensions\ms-python.autopep8-2024.0.0\bundled\tool
    C:\Program Files\Python312\python312.zip
    C:\Program Files\Python312\DLLs
    C:\Program Files\Python312\Lib
    C:\Program Files\Python312
    <path-to-workspace>\.venv
    <path-to-workspace>\.venv\Lib\site-packages
 2024-09-03 22:13:02.664 [info] PYTHONPATH env variable used to run Server:
    c:\Users\<user>\.vscode\extensions\ms-python.autopep8-2024.0.0\bundled\libs;
 2024-09-03 22:13:02.664 [info] Settings used to run Server:
 [
    {
       "cwd": "<path-to-workspace>",
       "workspace": "file:///<path-to-workspace>",
       "args": [],
       "path": [
             "autopep8"
       ],
       "interpreter": [
             "<path-to-workspace>\\.venv\\Scripts\\python.exe"
       ],
       "importStrategy": "useBundled",
       "showNotifications": "onWarning"
    }
 ]

 2024-09-03 22:13:02.664 [info] Global settings:
 {
    "cwd": "C:\\Program Files\\Microsoft VS Code",
    "workspace": "C:\\Program Files\\Microsoft VS Code",
    "args": [],
    "path": [],
    "interpreter": [],
    "importStrategy": "useBundled",
    "showNotifications": "onWarning"
 }

 2024-09-03 22:13:02.669 [info] autopep8 --version
 2024-09-03 22:13:02.670 [info] CWD Server: <path-to-workspace>
 2024-09-03 22:13:02.771 [info] Version info for formatter running for <path-to-workspace>:
 autopep8 2.1.0 (pycodestyle: 2.11.1)

 2024-09-03 22:13:02.771 [info] SUPPORTED autopep8>=1.7.0
 FOUND autopep8==2.1.0

 2024-09-03 22:13:02.773 [debug] Server State: Running

Outcome When Attempting Debugging Steps:

Did running it from the command line work? Yes, running autopep8 <path-to-file> in my .venv's terminal uses the version installed by pip.

Extra Details

  • What other Python-related extensions are you using? isort
  • What does your project structure look like? In Root: main.py, pyproject.toml, ... , .vscode/, src/*.py
  • Are you working in a multiroot workspace? No
  • Where is the config file for the current tool? .vscode/settings.json
  • Any extra settings from your workspace or user settings.json files?
"[python]": {
    "editor.defaultFormatter": "ms-python.autopep8",
    "editor.formatOnSave": true,
},
"autopep8.path": ["autopep8"]
@04Samir 04Samir added the bug Issue identified by VS Code Team member as probable bug label Sep 3, 2024
@karthiknadig
Copy link
Member

@04Samir From the logs it looks like the "importStrategy": "useBundled", (default) set it to "fromEnvironment" for the extension to use the one from your environment.

If you want to set path you can do it like this: "autopep8.path": ["${workspaceFolder}/.venv/scripts/autopep8.exe"] or "autopep8.path": ["${interpreter}", "-m", "autopep8"]

@karthiknadig karthiknadig closed this as not planned Won't fix, can't repro, duplicate, stale Sep 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issue identified by VS Code Team member as probable bug triage-needed
Projects
None yet
Development

No branches or pull requests

2 participants