New code
shell command fails if python
points to Python 3 #3790
Closed
Description
Just installed 0.10.10 and installed the code
shell command:
$ code --help
File "<string>", line 1
import os,sys; print os.path.realpath(sys.argv[1])
^
SyntaxError: invalid syntax
/usr/local/bin/code: line 10: ./MacOS/Electron: No such file or directory
VS Code itself works fine if I launch it via Spotlight.
I believe the problem is that I had a Python virtual environment active, and python
points to Python 3. If I try code
outside of that virtualenv, where python
means Python 2, everything works fine.
I guess the options are:
- Make the launch script Python 2/3 compatible. (Step one would probably be to add
from __future__ import print_function
and update theprint
statements accordingly.) - Do some extra work to guarantee that you launch the system Python and not the user's configured Python, though this is probably not a viable long-term approach since distributions like Fedora now default to Python 3 and don't even install Python 2 by default.