Phaty9912
Phaty9912

Reputation: 21

importing numba module shows ImportError

so i am currently using vs code with anaconda, both latest versions. When trying to import jit from numba like so,

from numba import jit
import numpy as np

x = np.arange(100).reshape(10, 10)

@jit(nopython=True) # Set "nopython" mode for best performance, equivalent to @njit
def go_fast(a): # Function is compiled to machine code when called the first time
    trace = 0.0
    for i in range(a.shape[0]):   # Numba likes loops
        trace += np.tanh(a[i, i]) # Numba likes NumPy functions
    return a + trace              # Numba likes NumPy broadcasting

print(go_fast(x))

as in the numba site, it gives the error,

ImportError: cannot import name 'jit' from partially initialized module 'numba' (most likely due to a circular import)

when i try

import numba
numba.__version__

it shows

'0.51.2'

i made sure that i am using the anaconda base environment, which is where numba was installed, included with anaconda

why is this issue occuring and how i can i solve this? any help would be appreciated

Upvotes: 2

Views: 4303

Answers (1)

afrodi
afrodi

Reputation: 31

Change the name of your python script and see if that works. :P

Upvotes: 3

Related Questions