Repository navigation
Closed
Description
Steps to reproduce:
- Install Python 3 and add it to PATH:
> python --version
Python 3.7.3
- Start as a usual user (not Administrator) at
C:\ git clone https://github.com/emscripten-core/emsdk.git(HEAD is at 4965260 at the moment)cd emsdkemsdk install latest-upstream- Open an Administrator terminal
cd C:\emsdkemsdk activate --global latest-upstream
Expected: successful activation.
Got:
Microsoft Windows [Version 10.0.18362.175]
(c) 2019 Microsoft Corporation. All rights reserved.
C:\Windows\system32>cd c:\emsdk
c:\emsdk>emsdk activate --global latest-upstream
Registering active Emscripten environment globally for all users.
Writing .emscripten configuration file to user home directory C:\Users\esuvorov/
Backing up old Emscripten configuration file in C:\Users\esuvorov\.emscripten.old
The Emscripten configuration file C:\Users\esuvorov\.emscripten has been rewritten with the following contents:
import os
LLVM_ROOT = 'c:/emsdk/upstream/bin'
BINARYEN_ROOT = 'c:/emsdk/upstream'
NODE_JS = 'c:/emsdk/node/8.9.1_64bit/bin/node.exe'
SPIDERMONKEY_ENGINE = ''
V8_ENGINE = ''
TEMP_DIR = 'C:/Users/esuvorov/AppData/Local/Temp'
COMPILER_ENGINE = NODE_JS
JS_ENGINES = [NODE_JS]
Adding directories to PATH:
PATH += c:\emsdk
PATH += c:\emsdk\upstream\emscripten
PATH += c:\emsdk\node\8.9.1_64bit\bin
Setting environment variables:
EMSDK = c:/emsdk
EM_CONFIG = C:\Users\esuvorov\.emscripten
EMSDK_NODE = c:\emsdk\node\8.9.1_64bit\bin\node.exe
Traceback (most recent call last):
File "c:\emsdk\\emsdk", line 286, in win_get_environment_variable
return os.environ[key]
File "C:\Users\esuvorov\AppData\Local\Programs\Python\Python37-32\lib\os.py", line 678, in __getitem__
raise KeyError(key) from None
KeyError: 'EMSDK_NODE'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "c:\emsdk\\emsdk", line 2697, in <module>
sys.exit(main())
File "c:\emsdk\\emsdk", line 2636, in main
tools_to_activate = set_active_tools(tools_to_activate, permanently_activate=arg_global)
File "c:\emsdk\\emsdk", line 2129, in set_active_tools
tool.win_activate_env_vars(permanently_activate=True)
File "c:\emsdk\\emsdk", line 1495, in win_activate_env_vars
win_delete_environment_variable(key, False) # If there is an env var for the LOCAL USER with same name, it will hide the system var, so must remove that first.
File "c:\emsdk\\emsdk", line 354, in win_delete_environment_variable
win_set_environment_variable(key, None, system)
File "c:\emsdk\\emsdk", line 316, in win_set_environment_variable
previous_value = win_get_environment_variable(key, system)
File "c:\emsdk\\emsdk", line 288, in win_get_environment_variable
if e[0] != 2: # 'The system cannot find the file specified.'
TypeError: 'KeyError' object is not subscriptable
c:\emsdk>
Looks like the problem is in win_get_environment_variable at the very least. Python 3 does not have pywin32 by default, so the first try fails, then os.environ[key] throws KeyError for non-existent variable, it is caught by the second except and everything fails when the code tries to access [0] of KeyError. It's ok for some reason in Python 2 ([0] simply returns the key of KeyError), but fails in Python 3, hence the error above.
Metadata
Metadata
Assignees
Labels
No labels
Activity
yeputons commentedon Jul 10, 2019
Extra info: that's a somewhat known incompatibility between Python 2 and Python 3, see here.
Workarounds:
latestfirst, which will install supported version of Python toc:\emsdk\pythonand thenemsdk.batwill pick it up.Quick fix: replace
e[0]withe.args[0](similarly inwin_set_environment_variable_direct):Full fix: rewrite the logic so it does not rely on
KeyErrorandwin32api.errorhaving[0].[windows] Replace python2-specific error handling with a string check…
kripken commentedon Jul 12, 2019
Thanks @yeputons! Please take a look at #300 which I opened now, does that fix the problem for you?
(I'm still not totally happy with the error handling there, but at least it should work in all python versions with that...)
[windows] Replace python2-specific error handling with a check that w…
Bump emscripten to 3.1.30 (2nd try) (emscripten-core#298)
Revert "Bump emscripten to 3.1.30 (2nd try) (emscripten-core#298)" (e…
Bump emscripten to 3.1.30 (2nd try) (emscripten-core#298)
Bump emscripten to 3.1.30 (2nd try) (emscripten-core#298)