* Owlready2 * Warning: optimized Cython parser module 'owlready2_optimized' is not available, defaulting to slower Python implementation

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

* Owlready2 * Warning: optimized Cython parser module 'owlready2_optimized' is not available, defaulting to slower Python implementation

emir
* Owlready2 * Warning: optimized Cython parser module 'owlready2_optimized' is not available, defaulting to slower Python implementation


I DO have Cython installed also a mgw C compiler but it doesn't get me to use the optimized module?

What am I doing wrong? Is there a specific way I should configure Cython to get to use MinGW compiler?
Reply | Threaded
Open this post in threaded view
|

Re: * Owlready2 * Warning: optimized Cython parser module 'owlready2_optimized' is not available, defaulting to slower Python implementation

Jiba
Administrator
Hi,

You should try the following import: "import Cython.Build". If it fails, Owlready setup disable the Cython module.

Possibly, some configuration is needed for using MinGW -- I never used it so I cannot help you on that topic.

The Cython parser module allows loading ontologies about 25% faster. Beyond that, you can entirely use Owlready without it.

Jiba
Reply | Threaded
Open this post in threaded view
|

Re: * Owlready2 * Warning: optimized Cython parser module 'owlready2_optimized' is not available, defaulting to slower Python implementation

emir
Thank you, Jiba.
Could you tell me what C compiler are you using? For linux or windows?
Reply | Threaded
Open this post in threaded view
|

Re: * Owlready2 * Warning: optimized Cython parser module 'owlready2_optimized' is not available, defaulting to slower Python implementation

Jiba
Administrator
I' using GCC under Linux.

Jiba
Reply | Threaded
Open this post in threaded view
|

Re: * Owlready2 * Warning: optimized Cython parser module 'owlready2_optimized' is not available, defaulting to slower Python implementation

emir
In reply to this post by Jiba
I did try importing Cython.Build, no errors. I ran in cmd 'gcc --version' and it output the following version:
'gcc (x86_64-posix-seh-rev0, Built by MinGW-W64 project) 8.1.0'.

But still when running my .py file, it shows the same warning.

At the beginning of the file I have the following lines

owlready2.JAVA_EXE = "C:/Program Files (x86)/Java/jre1.8.0_291/bin/java.exe"
owlready2.reasoning.JAVA_MEMORY = 1000

Is smth like that has to be done for Cython?

Reply | Threaded
Open this post in threaded view
|

Re: * Owlready2 * Warning: optimized Cython parser module 'owlready2_optimized' is not available, defaulting to slower Python implementation

Jiba
Administrator
Hi,

The JAVA_* constants deal with reasoning, but not at all with compilation of the C optimized module.

I think your problem is related to Cython and its configuration. Do you have some kind of error message when installing Owlready ? You may remove the "try:..." block that skip Cython compilation if the Cython module is not found, to be sure to get an error message.

Jiba
Reply | Threaded
Open this post in threaded view
|

Re: * Owlready2 * Warning: optimized Cython parser module 'owlready2_optimized' is not available, defaulting to slower Python implementation

emir
This post was updated on .
Okay, so I think I finally solved the issue.

So, when installing via pip, I couldn't find setup.py file in the owlready2 package folder. So I did a manual installation. Then go to owlready2/setup.py and between lines 60 and 90, you will find this block:
try:
  import Cython.Build
  extensions = [
    setuptools.Extension("owlready2_optimized", ["owlready2_optimized.pyx"]),
  ]
  extensions = Cython.Build.cythonize(extensions, compiler_directives = { "language_level" : 3 })
  dist = do_setup(extensions)
 
except:
  dist = do_setup([])

Comment it and add the inner part of try before or after the commented block. Run setup.py, and it might  work or you might struggle like me:

My problem was that I didn't have MS Visual C++ of the needed version. I downloaded the latest MS studio build tools and followed through the default installation.

After that, I had errors of not being able to find io.h. Fixed it with this reply on stackoverflow.

After that, I had LNK errors. Fixed it with this reply on stackoverflow.

Don't forget to restart your system after creating system variables.