question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Disable import sorting when using Python 2.7

See original GitHub issue
Error 2020-09-25 10:55:48:     runpy.run_path(module, run_name="__main__")
  File "C:\Python27\lib\runpy.py", line 252, in run_path
    return _run_module_code(code, init_globals, run_name, path_name)
  File "C:\Python27\lib\runpy.py", line 82, in _run_module_code
    mod_name, mod_fname, mod_loader, pkg_name)
  File "C:\Python27\lib\runpy.py", line 72, in _run_code
    exec code in run_globals
  File "c:\Users\<USER>\.vscode\extensions\ms-python.python-2020.9.111407\pythonFiles\sortImports.py", line 12, in <module>
    import isort.main
  File "c:\Users\<USER>\.vscode\extensions\ms-python.python-2020.9.111407\pythonFiles\lib\python\isort\__init__.py", line 2, in <module>
    from . import settings
  File "c:\Users\<USER>\.vscode\extensions\ms-python.python-2020.9.111407\pythonFiles\lib\python\isort\settings.py", line 31
    FILE_SKIP_COMMENTS: Tuple[str, ...] = (
                      ^
SyntaxError: invalid syntax

image

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:3
  • Comments:8 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
CHBrianLiucommented, Oct 22, 2020

Hi, I encountered this issue as well while using Python 2.7.17. For me, the workaround is to set python.sortImports.path explicitly in settings.json.

$ # Check isort version is 4.
$ isort --version

         isort your Python imports for you so you don't have to

                            VERSION 4.3.21

$ # Get isort path.
$ which isort
/home/brian_ch_liu/.local/bin/isort

In project directory, edit the VS code configuration file (.vscode/settings.json).

{
    "python.sortImports.path": "/home/brian_ch_liu/.local/bin/isort"
}
0reactions
karrtikrcommented, Dec 20, 2022

We no longer support Python 2.7 as its reached its EOL, hence closing this.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to turn off Sort Imports for a selection of files, glob or ...
Currently, you can't turn off import sorting an a per-module level through a VS Code-specific ...
Read more >
Programming FAQ — Python 3.11.1 documentation
How do I share global variables across modules? What are the “best practices” for using import in a module? Why are default values...
Read more >
sort-imports - ESLint - Pluggable JavaScript Linter
This rule checks all import declarations and verifies that all imports are first sorted by the used member syntax and then alphabetically by...
Read more >
Configuration options for isort
Tells isort to set the known standard library based on the specified Python version. Default is to assume any Python 3 version could...
Read more >
Sorting Algorithms in Python
Sorting is a basic building block that many other algorithms are built upon. ... 1from random import randint 2from timeit import repeat 3...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found