Reputation: 13519
I'm trying to open an editor in the terminal in pycharm, running the script below and am getting the error:
Error opening terminal: unknown.
The EDITOR
env var is set to /usr/bin/nano
.
The env var is being read correctly in the MVE below.
I can open the editor if I call $EDITOR
from the pycharm terminal command line directly.
The script works if called from a new terminal window, either inside or outside of pycharm.
The problem only arises when running it from a run configuration.
import os
import subprocess
def main():
editor = os.getenv('EDITOR')
with open('new.txt', 'w+') as tmp:
subprocess.call([editor, tmp.name])
if __name__ == "__main__":
main()
I've found a few related questions, but nothing that explains what the problem is.
Upvotes: 2
Views: 130
Reputation: 13519
The answer seems to be to check the [✓] Emulate terminal in output console
checkbox in the Run/Debug Configurations
window. This doesn't quite produce a functioning terminal session (there are issues with not seeing keyboard inputs after exiting the editor), but it works just well enough for my debugging purposes.
Upvotes: 1