If Python 3 is installed, emcc fails
Windows 10, I have Python 3 installed and on my PATH and just installed Emscripten.
When I run emcc:
File "C:\Program Files\Emscripten\emscripten\1.35.0\\emcc", line 134
''' % (open(shared.path_from_root('site', 'build', 'text', 'docs', 'tools_reference', 'emcc.txt')).read())
^
SyntaxError: invalid syntax
Although it installed its own Python 2 installation, my Python 3 installation is higher up on the PATH (as it should be!), and emcc.bat just refers to “python”:
@echo off
python "%~dp0\emcc" %*
instead of its own specific Python as it should (if it won’t work in Python 3), maybe like this:
@"%~dp0\..\..\python\2.7.5.3_64bit\python.exe" "%~dp0\emcc" %*
Try to activate emscripten by calling emsdk activate sdk-1.35.0-64bit or call emsdk_env.bat
Then system PATH will be modified, where local python will be chosen.
I installed Python 2.7.13 rather than the one provided in Emscripten. I also installed Python 3.6.0, since I use Python 3 more, it is located in PATH. All Emscripten scripts failed because Python 2 codes are feeded into Python 3, so I had to modified emsdk_env.bat to change PATH accordingly.
Python 3 comes with a useful program: Py Launcher to call out correct version of Python. py -2 to call latest Python 2, py -3 for Python 3 and py -X.Y for Python X.Y.
py is windows specific launcher.
Did you tried to activate emscripten first? Please note that this activation is temporal, so that it will work only in one CMD session.
I installed Python 2.7.13 not in emsdk's folder so I can't activate it with emsdk, I have other projects that require Python 2 so I don't want duplicates. Same goes to Node.js, I installed the latest version at C:\Program Files and changed .emscripten accordingly.
My current modification works for me, I was just sharing what I did to make it work.
I might be having this issue on CentOS 7.
This issue has been automatically marked as stale because there has been no activity in the past year. It will be closed automatically if no further activity occurs in the next 7 days. Feel free to re-open at any time if this issue is still relevant.