mandeep / sublime-text-conda

Work with conda environments in Sublime Text 3
BSD 3-Clause "New" or "Revised" License
26 stars 10 forks source link

Providing option for "shell": true #8

Closed cdyellick closed 5 years ago

cdyellick commented 6 years ago

I'm using sublime-text-conda with miniconda. I'm also using matplotlib and would like my plots to appear when run through the conda build system. However, if I install sublime-text-conda from package control and run something like this:

import matplotlib.pyplot as plt

print('start')
plt.axis()
plt.show()
print('end')

the plot is not shown and the program never reaches the end. From doing some research, it seems that Conda.sublime.build needs to contain "shell": true for my use case to work.

I was able to install sublime-text-conda form source and make the addition. Everything seems to work as I want now.

I assume there is a reason not to have this as the default behavior, but it would be nice to have it as an option.

mandeep commented 6 years ago

Thanks. I agree that there should be an option for shell=True. I do want to be careful about adding it though as there may be some unintended consequences especially on Windows.

pSpitzner commented 6 years ago

I had a similar issue and adding "shell"=true to the build system did not work.

In order for matplotlib to interact with the gui (on macOS), one needs to run it with pythonw instead of python when working with environments (e.g. conda). See this link for details.

Hence, I had to modify the commands.py of sublime-text-conda to use the right executable.

I think it would be nice to add an option in the sublime-settings for the shell flag and the python executable used for running the script.

mandeep commented 6 years ago

Thanks. Unfortunately, I don't have a Windows or macOS box to test with so PRs are greatly appreciated.

WBanner commented 2 years ago

Alternatively, in ST3 you can plot using pyplot by:

  1. Go to preferences->package settings-> conda->settings
  2. Add the option in user settings {"run_through_shell": true}. This will allow you to show figures upon plt.show(), but they will not hold
  3. Instead of plt.show() use plt.show(block=True)