gpoore / codebraid

Live code in Pandoc Markdown
BSD 3-Clause "New" or "Revised" License
376 stars 13 forks source link

Search path for Python executable on Windows #41

Closed draustin closed 3 years ago

draustin commented 3 years ago

I'm using Python 3.8 in a virtual environment provided by Poetry running on Windows 10. I find that the Python executable called by Codeweave does not respect the Windows PATH environment variable. Instead of calling the Python executable of the currently activated virtual environment (that Codebraid itself is running in), it calls a Windows system Python. By default, this produces a message referring you to the Microsoft store, and this message appears in the output HTML!

I tracked the issue down to the calls to subprocess.run in _subproc_default. There is a known issue with subprocess: https://bugs.python.org/issue15451

From this Stack Overflow answer I was able to fix the problem by inserting the following at the beginning of _subproc_default

args = [shutil.which(args[0])] + args[1:]

Thank you for Codebraid!