Question

I want to set the Python interpreter per project basis. The docs say:

You can of course configure the python interpreter to use in a per-project basis. To do that, you have to edit your .sublime-project file and override the python_interpreter user setting there:

{
    // ...

    "settings": {
        "python_interpreter": "/home/damnwidget/.virtualenvs/mamba-pypy/bin/python"
    }
}

This is what i have in my .sublime-project file:

{
    "folders":
    [
        {
            "follow_symlinks": true,
            "path": "C:\\Users\\Mads\\GoProjects"
        },
        {
            "follow_symlinks": true,
            "path": "C:\\Users\\Mads\\PythonProjects"
        }
    ]
}

I've tried many different combinations and i can't make out from the docs, where exactly should that setting go.

Was it helpful?

Solution

The full layout of a sample .sublime-project file can be found in the official docs:

{
    "folders":
    [
        {
            "path": "src",
            "folder_exclude_patterns": ["backup"],
            "follow_symlinks": true
        },
        {
            "path": "docs",
            "name": "Documentation",
            "file_exclude_patterns": ["*.css"]
        }
    ],
    "settings":
    {
        "tab_size": 8
    },
    "build_systems":
    [
        {
            "name": "List",
            "shell_cmd": "ls -l"
        }
    ]
}

So, the "settings" array should be on the same level as the "folders" one. In your case, your file should look like this:

{
    "folders":
    [
        {
            "follow_symlinks": true,
            "path": "C:\\Users\\Mads\\GoProjects"
        },
        {
            "follow_symlinks": true,
            "path": "C:\\Users\\Mads\\PythonProjects"
        }
    ],
    "settings":
    {
        "python_interpreter": "C:\\Users\\Mads\\.virtualenv\\MyProject\\usr\\bin\\python.exe"
    }
}

Obviously, you'll need to set the path to the actual location of your virtualenv's python.exe file.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top