Skip to content
This repository was archived by the owner on Apr 14, 2022. It is now read-only.
This repository was archived by the owner on Apr 14, 2022. It is now read-only.

Pass Python environment as parameter #1938

Closed

Description

I use mspyls with Neovim Language Client. The settings are statically defined in a settings.json and so is the InterpreterPath. I work with a lot of virtual environments so I want to define my Python binary location based on the project I'm working in.

settings.json

{
  "enabled": true,
  "initializationOptions": {
    "displayOptions": {
      "preferredFormat": "markdown",
      "trimDocumentationLines": true,
      "maxDocumentationLineLength": 0,
      "trimDocumentationText": true,
      "maxDocumentationTextLength": 0
    },
    "interpreter": {
      "properties": {
        "InterpreterPath": "/usr/bin/python",
        "UseDefaultDatabase": true,
        "Version": "3.8"
      }
    }
  }
}

Now my question arises, is it possible to define the InterpreterPath using terminal arguments?

For example:

dotnet /usr/local/lib/microsoft-python-language-server/Microsoft.Python.LanguageServer.dll \
    --python /usr/local/bin/python

Or is there a more simpler solution to my problem?

Activity

  1. jakebailey commented on Mar 13, 2020

    @jakebailey
    Member

    There is no such support at the moment, though I've personally considered a change (not sure in which issue) where providing no path/version will call out to python in PATH and fill in the required info, so if you run nvim with an environment activated this would be handled for you.

  2. LanderMoerkerke commented on Mar 13, 2020

    @LanderMoerkerke
    Author

    That would be a solution, I always open my vim buffers inside a virtualenv so the Python Path would be correct. I search in the issues to find the appropriate one.

  3. LanderMoerkerke commented on Mar 14, 2020

    @LanderMoerkerke
    Author

    I forked the repository with automatic generation of the InterpreterPath and its version. Its located at: MoerkerkeLander/python-language-server: Microsoft Language Server for Python.

  4. jakebailey commented on Mar 16, 2020

    @jakebailey
    Member

    Note that the method there isn't cross-platform; the correct method would be to look up PATH and then split on Path.PathSeparator to search for python.

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions