简体   繁体   中英

numba exception when run from inside IDE (VS2015)

I have visual studio 2015 with PTVS, tested with both Anaconda Python 3.4 and 3.5 (64 bit).

I get an exception immediately when the the script imports numba, this is a minimal example:

import numba

The exception is:

dictionary changed size during iteration

The exception originates from

envs\python3.5\Lib\site-packages\numba\config.py line 169

It appears that only inside VS the following code gives an error, note that it iterates over locals() and is updating globals()

for name, value in locals().items():
        if name.isupper():
            globals()[name] = value

Running the script from the Interactive window, in NVidia's Visual Profiler, jupyter notebook/command line interpreter works just fine so I suspect it must be something related to visual studio.

When I compare the contents of sys.modules between environments I find that visual studio imports some additional modules when debugging

'visualstudio_py_debugger',
'visualstudio_py_repl', 
'visualstudio_py_util'

Otherwise no differences between the environments. Also, scripts without numba don't throw any exceptions when importing them to VS. How can I fix this?

Outside of a function locals() and globals() refer to the same datastructure. Python does not allow changing a datastructure that is being iterated over. This has been fixed in the library in this commit https://github.com/numba/numba/commit/e50ab6ee4d95192d364cccced36cf0889860d023

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM