Skip to content

Different python version in neovim python3 host and virtualenv python #19

Open

Description

@wookayin

Consider a case where g:python3_host_prog is set to /usr/bin/python (3.5.x), and the current shell (e.g. $PATH) uses another python from virtualenv or anaconda, with different version (3.6.x).

In this case, Syntax from python 3.6+ is not supported. e.g.

   99 var = 1
E>100 print(f'{var}')

Output of :Semshi error is

Syntax error: invalid syntax (100, 14)

Is this a neovim-related issue? Can we configure python being used in code checking other than neovim's host python (or autodetect from $PATH)?

Activity

  1. numirias commented on Sep 19, 2018

    @numirias
    Owner

    Thanks for raising this, I knew someone would eventually do. It's a known limitation which doesn't make it less of a problem though. From the README:

    Semshi works with the same syntax version as your Neovim Python 3 provider. This means you can't use Semshi on code that's Python 2-only or uses incompatible syntax features.

    Semshi is simply retrieving the AST via Python's ast module which depends on the version of the Python provider which is running the plugin.

    But thinking about it, there may be viable workarounds to get AST and symtable via another Python distribution. I'll investigate if it's feasible to e.g. get the information doing IPC with a different Python process (seems like a significant overhead) or cross-import the modules between versions (which sounds like it's going to get messy) and let you know.

  2. added
    enhancement
    on Sep 23, 2018
  3. wookayin commented on Nov 7, 2018

    @wookayin
    ContributorAuthor

    So the current approach I am using (and, what I'd recommend) is to set correct g:python3_host_prog as the path your python interpreter, inside the virtualenv/condaenv. This variable could be set dynamically on neovim startup.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions