rajeshrinet / pyross

PyRoss: inference, forecasts, and optimised control of epidemiological models in Python. github.com/rajeshrinet/pyross
https://pyross.readthedocs.io
MIT License
169 stars 57 forks source link

Cython Compile Error ' Converting to Python object not allowed without gil' during installation #14

Closed technOslerphile closed 4 years ago

technOslerphile commented 4 years ago

Hi,

I am facing issues whilst trying to install this library. I have Anaconda3, Python 3.7 and Cython 0.29.13.

pyross\deterministic.pyx:431:37: Converting to Python object not allowed without gil

Error compiling Cython file:
------------------------------------------------------------
...
            aa = bb*S[i]
            X[i]     = -aa
            X[i+M]   = aa - gI*I[i]

            for j in range(kk-1):
                X[i+(j+2)*M]   = gI*I[i+j*M] - gIa*I[i+(j+1)*M]
                                                 ^
------------------------------------------------------------

pyross\deterministic.pyx:431:50: Converting to Python object not allowed without gil
Traceback (most recent call last):
  File "setup.py", line 59, in <module>
    compiler_directives={"language_level": sys.version_info[0]},
  File "C:\Anaconda3\lib\site-packages\Cython\Build\Dependencies.py", line 1096, in cythonize
    cythonize_one(*args)
  File "C:\Anaconda3\lib\site-packages\Cython\Build\Dependencies.py", line 1219, in cythonize_one
    raise CompileError(None, pyx_file)
Cython.Compiler.Errors.CompileError: pyross\deterministic.pyx
rajeshrinet commented 4 years ago

@technOslerphile please can you pull the latest version and try again? Thanks.

Edit: It should work now.

technOslerphile commented 4 years ago

@rajeshrinet Thanks! It worked and the error mentioned in the original post is now solved.

However, I got two errors later which are:

1. vcvarsall.bat not found
2. cl.exe not found

I was able to fix these by installing Microsoft Visual Studio as mentioned here: https://stackoverflow.com/questions/2817869/error-unable-to-find-vcvarsall-bat/60396650#60396650 Hope this will be useful to those who are having some issues in Windows.

By the way, your paper is phenomenal. I have never really found much COVID-19 mathematical model papers with this much clarity. Thank you very much!

rajeshrinet commented 4 years ago

@technOslerphile thanks very much for your kind words.

The solution for windows is very useful. I will share it with others. Thank you!