peter-ch / MultiNEAT

Portable NeuroEvolution Library
http://MultiNEAT.com
GNU Lesser General Public License v3.0
328 stars 104 forks source link

Install problem with python 3.5 on Ubuntu 16.04 with Cython #36

Open njvanbal opened 6 years ago

njvanbal commented 6 years ago

I am getting the following error when trying to install with cython. Not sure if it is a version problem, or if I am misunderstanding the build process.

Compiling _MultiNEAT.pyx because it changed.
[1/1] Cythonizing _MultiNEAT.pyx

Error compiling Cython file:
------------------------------------------------------------
...
    def __dealloc__(self):
        if not self.borrowed:
            del self.thisptr

    def __repr__(self):
        return 'ID {} Age {}'.format(self.thisptr.ID(), self.thisptr.Age())
                                                                   ^
------------------------------------------------------------

_MultiNEAT.pyx:953:68: Object of type 'Species' has no attribute 'Age'
Traceback (most recent call last):
  File "setup.py", line 96, in <module>
    ext_modules=getExtensions())
  File "setup.py", line 71, in getExtensions
    extra_compile_args=extra)],
  File "/usr/local/lib/python3.5/dist-packages/Cython/Build/Dependencies.py", line 1039, in cythonize
    cythonize_one(*args)
  File "/usr/local/lib/python3.5/dist-packages/Cython/Build/Dependencies.py", line 1161, in cythonize_one
    raise CompileError(None, pyx_file)
Cython.Compiler.Errors.CompileError: _MultiNEAT.pyx
njvanbal commented 6 years ago

I also tried removing the reference to age and am getting the following error, I have confirmed that the constructor in the Genome file does in fact have 9 arguments, but for some reason Cython thinks it has 10.

_MultiNEAT.cpp:19088:166: error: no matching function for call to ‘NEAT::Genome::Genome(unsigned int&, unsigned int&, unsigned int&, unsigned int&, bool&, NEAT::ActivationFunction&, NEAT::ActivationFunction&, unsigned int&, NEAT::Parameters&)’
     __pyx_v_self->thisptr = new NEAT::Genome(__pyx_t_17, __pyx_t_18, __pyx_t_19, __pyx_t_20, __pyx_t_21, __pyx_t_22, __pyx_t_23, __pyx_t_24, (*__pyx_v_a_ps->thisptr));
                                                                                                                                                                      ^
In file included from src/Innovation.h:37:0,
                 from src/Population.h:36,
                 from _MultiNEAT.cpp:589:
src/Genome.h:193:9: note: candidate: NEAT::Genome::Genome(unsigned int, unsigned int, unsigned int, unsigned int, bool, NEAT::ActivationFunction, NEAT::ActivationFunction, unsigned int, const NEAT::Parameters&, unsigned int)
         Genome(unsigned int a_ID,
         ^
src/Genome.h:193:9: note:   candidate expects 10 arguments, 9 provided
src/Genome.h:189:9: note: candidate: NEAT::Genome::Genome(unsigned int, unsigned int, unsigned int, unsigned int, NEAT::ActivationFunction, NEAT::ActivationFunction, const NEAT::Parameters&)
         Genome(unsigned int a_ID, unsigned int a_NumInputs, unsigned int a_NumHidden, unsigned int a_NumOutputs,
         ^
src/Genome.h:189:9: note:   candidate expects 7 arguments, 9 provided
src/Genome.h:186:9: note: candidate: NEAT::Genome::Genome(std::ifstream&)
         Genome(std::ifstream &a_DataFile);
         ^
src/Genome.h:186:9: note:   candidate expects 1 argument, 9 provided
src/Genome.h:183:9: note: candidate: NEAT::Genome::Genome(const char*)
         Genome(const char *a_filename);
         ^
src/Genome.h:183:9: note:   candidate expects 1 argument, 9 provided
src/Genome.h:170:9: note: candidate: NEAT::Genome::Genome(const NEAT::Genome&)
         Genome(const Genome &a_g);
         ^
src/Genome.h:170:9: note:   candidate expects 1 argument, 9 provided
src/Genome.h:167:9: note: candidate: NEAT::Genome::Genome()
         Genome();
         ^
src/Genome.h:167:9: note:   candidate expects 0 arguments, 9 provided
error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
joel-simon commented 6 years ago

fix seems to be an older version

lionliam96 commented 6 years ago

I`m having the same issue (using Cython on Ubuntu 16.04 (x86_64)). Have tried two machines with the same OS but no luck.

@Sloth6 Older version of what?

joel-simon commented 6 years ago

An older commit. But I would recommend just using the boost version which fixes the issue. Cython seems not supported recently, it isn't documented but things like genome pickling (and therefore parallelism) and traits don't work with cython.

peter-ch commented 6 years ago

The Cython stuff is way out of date, I'm using Boost for development and all new features rely on it.

anton-matosov commented 6 years ago

it doesn't compile even with boost src/PythonBindings.h:31:10: fatal error: 'boost/python/numeric.hpp' file not found Since boost 1.65 numeric.hpp is deprecated in favor of numpy.hpp

anton-matosov commented 6 years ago

I have updated MultiNEAT to build with boost 1.65 and created conda package out of it. I will create PR shortly

peter-ch commented 6 years ago

Thanks!

RiseOoi commented 6 years ago

I am facing the exact same problem. Exact same error message with MN_Build=cython

anton-matosov commented 6 years ago

cython is no longer supported. currently build works only with boost I have added a Conda support, so you can grab pre-build binaries. Currently packages are available from my personal channel with boost from conda-forge: conda install multineat -c anton.matosov -c conda-forge

In future I want to submit it as feedstock to conda-forge to make re-distribution easy.

More details of changes and how this build was created are here https://github.com/peter-ch/MultiNEAT/pull/45