Search code examples
sublimetextanaconda3

Sublimetext suddenly won't build .py script (Anaconda3). KeyError: 'conda_environment'


SOLVED. Apparently I somehow deactivated my Conda environment. Typing Conda: Activate Environment into the Sublime console fixed it.

I'm using Anaconda3 to run scripts developed at my workplace. I had set up SublimeText to view/edit the scripts and to run them using the build command. Until today, I had been able to run scripts normally.

Today, however, some of the commands are not enclosed with white boxes and I get an error command which trying to build the script.Here's a screenshot showing the markings and error message

I first restarted my computer to no avail. I then uninstalled and re-installed packages for Conda and Anaconda but that also failed to fix it. Googling "sublime conda not building" gave me results which concerned error messages while building a script and not being unable to build entirely. I also can't find a match to my specific error message.

Any insight? If it's not obvious, I am a novice to python & sublime. Thanks.

EDIT: The white boxes are now gone. More importantly, apparently they're related to linting and are (likely) not related to the script not building which is the primary concern.

EDIT2: URLS for plugins Conda and Anaconda

I wasn't able to find conda.sublime-build, but I found conda.sublime-settings which I think is the same thing. If not, please let me know where to look. (this was under user packages). These settings are pasted below.

// Default Windows settings for sublime-text-conda:
{
    // executable is the path to anaconda's python
    // this python executable is used in order to find conda
    "executable": "C:\\Users\\26036\\Anaconda3\\python.exe",

    // Directory in which the conda envs are stored
    // Default location is the user's home directory
    "environment_directory": "C:\\Users\\26036\\Anaconda3\\envs\\",
    
    // System architecture for Python installation
    // options: 32 or 64 bit
    "architecture": "64",

    // configuration is the path to conda's configuration file
    "configuration": "~\\.condarc",

    // when true, the scripts will be run through the shell
    // If your code has a GUI (e.g. a matplotlib plot),
    // this needs to be true, otherwise Windows suppresses it.
    "run_through_shell": false,

    // when true, the script execution will be handed over to
    // the pythonw executable, instead of python
    "use_pythonw": false,

    // open repl in second row tab below current file,
    // closing any existing tabs in that area
    // assumes files are kept in group 0 (typical)
    "repl_open_row": false,

    // when opening a repl using repl_open_row, close any
    // existing conda repls in the second row first
    "repl_row_close_existing": false,

    // save the current file (if dirty) when opening repl
    "repl_save_dirty": true,

    // syntax highlighting for Open REPL command
    // choice between 'python' and 'plaintext'
    "repl_syntax": "python"
}

EDIT3: I have both Conda and Anaconda3 packages installed. When it was working, I selected Conda as my build system. I'm sorta sure the environment was activated because I was able to run the script beforehand but perhaps the environment got deactivated?


Solution

  • Turns out my Conda environment was somehow made inactive. Typing "Conda: Activate Environment" in the Sublime Console fixed it. Thanks MattDMo for suggesting I check it.