Error compiling Cython File while installing

53 views
Skip to first unread message

tong2...@gmail.com

unread,
Jan 31, 2018, 4:34:56 AM1/31/18
to LatticeWordSegmentation
Hi,
Thanks a lot for the script on git (https://github.com/fgnt/nhpylm.git).
I met some problem while installing it with the command 'pip install --user -e .'
I was installing on ubuntu 16.04, python3.5, cython0.27.3.

The error messages are as follows. 

Obtaining file:///home/wuyt/nhpylm Complete output from command python setup.py egg_info: -- The C compiler identification is GNU 5.4.0 -- The CXX compiler identification is GNU 5.4.0 -- Check for working C compiler: /usr/bin/cc -- Check for working C compiler: /usr/bin/cc -- works -- Detecting C compiler ABI info -- Detecting C compiler ABI info - done -- Detecting C compile features -- Detecting C compile features - done -- Check for working CXX compiler: /usr/bin/c++ -- Check for working CXX compiler: /usr/bin/c++ -- works -- Detecting CXX compiler ABI info -- Detecting CXX compiler ABI info - done -- Detecting CXX compile features -- Detecting CXX compile features - done CMake Warning (dev) in CMakeLists.txt: No cmake_minimum_required command is present. A line of code such as cmake_minimum_required(VERSION 3.5) should be added at the top of the file. The version specified may be lower if you wish to support older CMake versions for this project. For more information run "cmake --help-policy CMP0000". This warning is for project developers. Use -Wno-dev to suppress it. -- Configuring done -- Generating done -- Build files have been written to: /home/wuyt/nhpylm/nhpylm/c_core/NHPYLM/build Scanning dependencies of target NHPYLM [ 20%] Building CXX object CMakeFiles/NHPYLM.dir/Restaurant.o [ 40%] Building CXX object CMakeFiles/NHPYLM.dir/HPYLM.o [ 60%] Building CXX object CMakeFiles/NHPYLM.dir/Dictionary.o [ 80%] Building CXX object CMakeFiles/NHPYLM.dir/NHPYLM.o [100%] Linking CXX static library libNHPYLM.a [100%] Built target NHPYLM Warning: Extension name 'nhpylm.c_core.nhpylm' does not match fully qualified name 'c_core.nhpylm' of 'nhpylm/c_core/nhpylm.pyx' Compiling nhpylm/c_core/nhpylm.pyx because it changed. [1/1] Cythonizing nhpylm/c_core/nhpylm.pyx Error compiling Cython file: ------------------------------------------------------------ ... vector[int] Words vector[int] NextContextIds vector[double] Probabilities bool HasTransitionToSentEnd cdef struct NHPYLMParameters: const vector[double] &CHPYLMDiscount ^ ------------------------------------------------------------ nhpylm/c_core/nhpylm.pxd:76:33: C++ references cannot be declared; use a pointer instead Error compiling Cython file: ------------------------------------------------------------ ... vector[int] NextContextIds vector[double] Probabilities bool HasTransitionToSentEnd cdef struct NHPYLMParameters: const vector[double] &CHPYLMDiscount const vector[double] &CHPYLMConcentration ^ ------------------------------------------------------------ nhpylm/c_core/nhpylm.pxd:77:33: C++ references cannot be declared; use a pointer instead Error compiling Cython file: ------------------------------------------------------------ ... vector[double] Probabilities bool HasTransitionToSentEnd cdef struct NHPYLMParameters: const vector[double] &CHPYLMDiscount const vector[double] &CHPYLMConcentration const vector[double] &WHPYLMDiscount ^ ------------------------------------------------------------ nhpylm/c_core/nhpylm.pxd:78:33: C++ references cannot be declared; use a pointer instead Error compiling Cython file: ------------------------------------------------------------ ... bool HasTransitionToSentEnd cdef struct NHPYLMParameters: const vector[double] &CHPYLMDiscount const vector[double] &CHPYLMConcentration const vector[double] &WHPYLMDiscount const vector[double] &WHPYLMConcentration ^ ------------------------------------------------------------ nhpylm/c_core/nhpylm.pxd:79:33: C++ references cannot be declared; use a pointer instead Error compiling Cython file: ------------------------------------------------------------ ... def word_model_word_count(self): return self._lm.GetTotalCountPerLevelFor(b'WHPYLM', b'Word') @property def hyperparameter(self): return self._lm.GetNHPYLMParameters() ^ ------------------------------------------------------------ nhpylm/c_core/nhpylm.pyx:155:43: Cannot convert 'const NHPYLMParameters &' to Python object Traceback (most recent call last): File "<string>", line 1, in <module> File "/home/wuyt/nhpylm/setup.py", line 78, in <module> )], annotate=True) File "/home/wuyt/anaconda2/envs/tf1.0/lib/python3.5/site-packages/Cython/Build/Dependencies.py", line 1039, in cythonize cythonize_one(*args) File "/home/wuyt/anaconda2/envs/tf1.0/lib/python3.5/site-packages/Cython/Build/Dependencies.py", line 1161, in cythonize_one raise CompileError(None, pyx_file) Cython.Compiler.Errors.CompileError: nhpylm/c_core/nhpylm.pyx ---------------------------------------- Command "python setup.py egg_info" failed with error code 1 in /home/wuyt/nhpylm/


Thanks and kind regards,
Tong

Lulamile Mzamo

unread,
Feb 7, 2018, 12:29:31 PM2/7/18
to LatticeWordSegmentation
Hi,

I echo Tong on thanking you guys for nhpylm.

I have the exact problem as Tong, I'm installing nhpylm on Cygwin running on Windows 10. python 3.6.4 and cython 0.27.3.

Regards,
Lula

btd...@fit.hcmus.edu.vn

unread,
Jul 1, 2019, 8:43:55 AM7/1/19
to LatticeWordSegmentation
Hi, 

Did you solve the error? I also encountered error when trying compile nhpylm on my machine. Could you please help? Thank you very much. 
The installer is run on Mac 10.14.5. python 3.6. And this is the error I got.

-- The C compiler identification is Clang 4.0.1

-- The CXX compiler identification is Clang 4.0.1

-- Check for working C compiler: /Users/danhbuithi/miniconda3/bin/x86_64-apple-darwin13.4.0-clang

-- Check for working C compiler: /Users/danhbuithi/miniconda3/bin/x86_64-apple-darwin13.4.0-clang -- broken

CMake Error at /usr/local/Cellar/cmake/3.13.0/share/cmake/Modules/CMakeTestCCompiler.cmake:52 (message):

  The C compiler


    "/Users/danhbuithi/miniconda3/bin/x86_64-apple-darwin13.4.0-clang"


  is not able to compile a simple test program.


  It fails with the following output:


    Change Dir: /Users/danhbuithi/Downloads/nhpylm/nhpylm/c_core/NHPYLM/build/CMakeFiles/CMakeTmp

    

    Run Build Command:"/usr/bin/make" "cmTC_ea72e/fast"

    /Applications/Xcode.app/Contents/Developer/usr/bin/make -f CMakeFiles/cmTC_ea72e.dir/build.make CMakeFiles/cmTC_ea72e.dir/build

    Building C object CMakeFiles/cmTC_ea72e.dir/testCCompiler.c.o

    /Users/danhbuithi/miniconda3/bin/x86_64-apple-darwin13.4.0-clang   -march=core2 -mtune=haswell -mssse3 -ftree-vectorize -fPIC -fPIE -fstack-protector-strong -O2 -pipe  -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk   -o CMakeFiles/cmTC_ea72e.dir/testCCompiler.c.o   -c /Users/danhbuithi/Downloads/nhpylm/nhpylm/c_core/NHPYLM/build/CMakeFiles/CMakeTmp/testCCompiler.c

    Linking C executable cmTC_ea72e

    /usr/local/Cellar/cmake/3.13.0/bin/cmake -E cmake_link_script CMakeFiles/cmTC_ea72e.dir/link.txt --verbose=1

    /Users/danhbuithi/miniconda3/bin/x86_64-apple-darwin13.4.0-clang -march=core2 -mtune=haswell -mssse3 -ftree-vectorize -fPIC -fPIE -fstack-protector-strong -O2 -pipe  -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk -Wl,-search_paths_first -Wl,-headerpad_max_install_names -Wl,-pie -Wl,-headerpad_max_install_names -Wl,-dead_strip_dylibs  CMakeFiles/cmTC_ea72e.dir/testCCompiler.c.o  -o cmTC_ea72e 

    ld: warning: ignoring file /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/usr/lib/libSystem.tbd, file was built for unsupported file format ( 0x2D 0x2D 0x2D 0x20 0x21 0x74 0x61 0x70 0x69 0x2D 0x74 0x62 0x64 0x2D 0x76 0x33 ) which is not the architecture being linked (x86_64): /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/usr/lib/libSystem.tbd

    ld: dynamic main executables must link with libSystem.dylib for architecture x86_64

    clang-4.0: error: linker command failed with exit code 1 (use -v to see invocation)

    make[1]: *** [cmTC_ea72e] Error 1

    make: *** [cmTC_ea72e/fast] Error 2

    


  


  CMake will not be able to correctly generate this project.



CMake Warning (dev) in CMakeLists.txt:

  No cmake_minimum_required command is present.  A line of code such as


    cmake_minimum_required(VERSION 3.13)


  should be added at the top of the file.  The version specified may be lower

  if you wish to support older CMake versions for this project.  For more

  information run "cmake --help-policy CMP0000".

This warning is for project developers.  Use -Wno-dev to suppress it.


-- Configuring incomplete, errors occurred!

See also "/Users/danhbuithi/Downloads/nhpylm/nhpylm/c_core/NHPYLM/build/CMakeFiles/CMakeOutput.log".

See also "/Users/danhbuithi/Downloads/nhpylm/nhpylm/c_core/NHPYLM/build/CMakeFiles/CMakeError.log".

make: *** No targets specified and no makefile found.  Stop.

Compiling nhpylm/c_core/nhpylm.pyx because it changed.

[1/1] Cythonizing nhpylm/c_core/nhpylm.pyx

/Users/danhbuithi/miniconda3/lib/python3.7/site-packages/Cython/Compiler/Main.py:367: FutureWarning: Cython directive 'language_level' not set, using 2 for now (Py2). This will change in a later release! File: /Users/danhbuithi/Downloads/nhpylm/nhpylm/c_core/nhpylm.pyx

  tree = Parsing.p_module(s, pxd, full_module_name)


Error compiling Cython file:

------------------------------------------------------------

...

    :param symbols: List of symbols used to represent words

    :param word_model_order: Order of the word model

    :param character_model_order: Order of the character model


    """

    cdef NHPYLM* _lm

        ^

------------------------------------------------------------


nhpylm/c_core/nhpylm.pyx:65:9: 'NHPYLM' is not a type identifier


Error compiling Cython file:

------------------------------------------------------------

...

        cdef int cur_context

        cdef int dest

        cdef int label

        cdef float weight

        cdef int i

        cdef ContextToContextTransitions transitions

            ^

------------------------------------------------------------


nhpylm/c_core/nhpylm.pyx:340:13: 'ContextToContextTransitions' is not a type identifier


Error compiling Cython file:

------------------------------------------------------------

...

            self._int_to_sym[i] = symbols[i].encode()


        cdef vector[string] sym_vec

        for sym in symbols:

            sym_vec.push_back(sym.encode())

        self._lm = new NHPYLM(character_model_order, word_model_order,

                      ^

------------------------------------------------------------


nhpylm/c_core/nhpylm.pyx:83:23: 'NHPYLM' is not a type identifier


Error compiling Cython file:

------------------------------------------------------------

...

            self._int_to_sym[i] = symbols[i].encode()


        cdef vector[string] sym_vec

        for sym in symbols:

            sym_vec.push_back(sym.encode())

        self._lm = new NHPYLM(character_model_order, word_model_order,

                      ^

------------------------------------------------------------


nhpylm/c_core/nhpylm.pyx:83:23: new operator can only be applied to a C++ class


Error compiling Cython file:

------------------------------------------------------------

...

            self._sentence_boundary_id = self._sym_to_int[sentence_boundary_marker]


    cdef int _add_word(self, word):

        cdef vector[int] word_vec = [self._sym_to_int[c] for c in word]

        word_id, _ = self._lm.AddCharacterIdSequenceToDictionary(

            word_vec.const_begin(), word_vec.size()

                               ^

------------------------------------------------------------


nhpylm/c_core/nhpylm.pyx:95:32: Cannot convert 'const_iterator' to Python object


Error compiling Cython file:

------------------------------------------------------------

...

        """ Returns the id for a specific word


        :param word:

        """

        cdef vector[int] word_vec = [self._sym_to_int[c] for c in word]

        return self._lm.GetWordId(word_vec.const_begin(),

                                                     ^

------------------------------------------------------------


nhpylm/c_core/nhpylm.pyx:109:54: Cannot convert 'const_iterator' to Python object

Traceback (most recent call last):

  File "setup.py", line 78, in <module>

    )], annotate=True)

  File "/Users/danhbuithi/miniconda3/lib/python3.7/site-packages/Cython/Build/Dependencies.py", line 1097, in cythonize

    cythonize_one(*args)

  File "/Users/danhbuithi/miniconda3/lib/python3.7/site-packages/Cython/Build/Dependencies.py", line 1220, in cythonize_one

    raise CompileError(None, pyx_file)

Cython.Compiler.Errors.CompileError: nhpylm/c_core/nhpylm.pyx


Reply all
Reply to author
Forward
0 new messages