Pycharm is not reflecting the environment variable I set in a code cell. The following code runs in Pycharm (hitting play on the entire script):
#%% <- Scientific Mode: onimport osfrom pathlib import PathCACHE_DIR = Path("/home/me/numba_cache")CACHE_DIR.touch(exist_ok=True)os.environ["NUMBA_CACHE_DIR"] = str(CACHE_DIR)from numba import jit@jit(nopython=True, cache=True)def square(x): return x ** 2print(square(5))
However when I run the code cell, I get this error:
Traceback (most recent call last): File "/home/me/.pycharm_helpers/pydev/pydevconsole.py", line 364, in runcode coro = func() ^^^^^^ File "<input>", line 11, in <module> File "/home/me/.pyenv/versions/3.11.1/envs/my_env/lib/python3.11/site-packages/numba/core/decorators.py", line 234, in wrapper disp.enable_caching() File "/home/me/.pyenv/versions/3.11.1/envs/my_env/lib/python3.11/site-packages/numba/core/dispatcher.py", line 863, in enable_caching self._cache = FunctionCache(self.py_func) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/me/.pyenv/versions/3.11.1/envs/my_env/lib/python3.11/site-packages/numba/core/caching.py", line 601, in __init__ self._impl = self._impl_class(py_func) ^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/me/.pyenv/versions/3.11.1/envs/my_env/lib/python3.11/site-packages/numba/core/caching.py", line 337, in __init__ raise RuntimeError("cannot cache function %r: no locator available "RuntimeError: cannot cache function 'square': no locator available for file '<input>'
How do I get this to work? I've tried setting the env var in the run configuration, however that only works when the script is run, not an individual code cell