andompesta / ComE

Implementation of ComE algorithm
59 stars 32 forks source link

I have some trobule when running the code #2

Open yangyang20171121 opened 6 years ago

yangyang20171121 commented 6 years ago

I clone the project from github, the runtime environment are python3.6.1, cpython0.25. The error is described below:

File "E:/ComE/ADSCModel/context_embeddings.py", line 15, in from utils.training_sdg_inner import train_o2, loss_o2, FAST_VERSION ModuleNotFoundError: No module named 'utils.training_sdg_inner'

please tell me, what did I miss!

SeekPoint commented 6 years ago

the same problemn

dongwu92 commented 6 years ago
  1. compile training_sdg_inner at root dir

    sudo python3 cython_utils.py install

  2. install networkx with version of 1.11

    sudo python3 -m pip install networkx==1.11

  3. copy voidptr.h into build directory

  4. imsert the following code at the front of main.py

    import pyximport

    pyximport.install()

TimRepke commented 5 years ago

Hi, I run into the same problem and tried to adapt with the steps @PetroWu suggested. However, I still have problems compiling the code. Maybe someone could help me, I haven't really used Cython yet and don't know what to look out for. Any hints or help are much appreciated. Thanks :-)

% conda env create -f env.yml                                                                                                                                     
Solving environment: done
Preparing transaction: done
Verifying transaction: done
Executing transaction: done
Collecting gensim==0.10.2 (from -r /home/tim/Uni/HPI/workspace/ComE/ComE/condaenv.gu9vbtvy.requirements.txt (line 1))
Requirement already satisfied: six>=1.2.0 in /home/tim/miniconda3/envs/ComE/lib/python3.6/site-packages (from gensim==0.10.2->-r /home/tim/Uni/HPI/workspace/ComE/ComE/condaenv.gu9vbtvy.requirements.txt (line 1))
Requirement already satisfied: scipy>=0.7.0 in /home/tim/miniconda3/envs/ComE/lib/python3.6/site-packages (from gensim==0.10.2->-r /home/tim/Uni/HPI/workspace/ComE/ComE/condaenv.gu9vbtvy.requirements.txt (line 1))
Installing collected packages: gensim
Successfully installed gensim-0.10.2
#
# To activate this environment, use
#
#     $ conda activate ComE
#
# To deactivate an active environment, use
#
#     $ conda deactivate

  11.59s user 1.32s system 95% cpu 13.487 total

% conda activate ComE
% python cython_utils.py install                                                                                                                                  :(
running install
running build
running build_ext
building 'utils.training_sdg_inner' extension
creating build
creating build/temp.linux-x86_64-3.6
creating build/temp.linux-x86_64-3.6/utils
gcc -pthread -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -Iutils -I/home/tim/miniconda3/envs/ComE/lib/python3.6/site-packages/numpy/core/include -I/home/tim/miniconda3/envs/ComE/include/python3.6m -c utils/training_sdg_inner.c -o build/temp.linux-x86_64-3.6/utils/training_sdg_inner.o
In file included from /home/tim/miniconda3/envs/ComE/lib/python3.6/site-packages/numpy/core/include/numpy/ndarraytypes.h:1788,
                 from /home/tim/miniconda3/envs/ComE/lib/python3.6/site-packages/numpy/core/include/numpy/ndarrayobject.h:18,
                 from /home/tim/miniconda3/envs/ComE/lib/python3.6/site-packages/numpy/core/include/numpy/arrayobject.h:4,
                 from utils/training_sdg_inner.c:493:
/home/tim/miniconda3/envs/ComE/lib/python3.6/site-packages/numpy/core/include/numpy/npy_1_7_deprecated_api.h:15:2: warning: #warning "Using deprecated NumPy API, disable it by " "#defining NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION" [-Wcpp]
 #warning "Using deprecated NumPy API, disable it by " \
  ^~~~~~~
utils/training_sdg_inner.c: In function ‘__pyx_pf_5utils_18training_sdg_inner_loss_o1’:
utils/training_sdg_inner.c:3400:7: warning: variable ‘__pyx_v_codelens’ set but not used [-Wunused-but-set-variable]
   int __pyx_v_codelens[0x2710];
       ^~~~~~~~~~~~~~~~
utils/training_sdg_inner.c: In function ‘__pyx_pf_5utils_18training_sdg_inner_4train_o1’:
utils/training_sdg_inner.c:4682:7: warning: variable ‘__pyx_v_codelens’ set but not used [-Wunused-but-set-variable]
   int __pyx_v_codelens[0x2710];
       ^~~~~~~~~~~~~~~~
utils/training_sdg_inner.c: In function ‘__pyx_pf_5utils_18training_sdg_inner_loss_o1.isra.11’:
utils/training_sdg_inner.c:3671:31: warning: ‘__pyx_v_indexes[0]’ may be used uninitialized in this function [-Wmaybe-uninitialized]
         __pyx_v_next_random = __pyx_f_5utils_18training_sdg_inner_loss_o1_o2(__pyx_v_negative, __pyx_v_table, __pyx_v_table_len, __pyx_v_node_embedding, __pyx_v_node_embedding, __pyx_v_size, (__pyx_v_indexes[1]), (__pyx_v_indexes[0]), __pyx_v_5utils_18training_sdg_inner_ONEF, __pyx_v_loss, __pyx_v_work, __pyx_v_next_random);
                               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
utils/training_sdg_inner.c:3671:31: warning: ‘__pyx_v_indexes[1]’ may be used uninitialized in this function [-Wmaybe-uninitialized]
utils/training_sdg_inner.c: In function ‘__pyx_pf_5utils_18training_sdg_inner_4train_o1.isra.9’:
utils/training_sdg_inner.c:4954:31: warning: ‘__pyx_v_indexes[0]’ may be used uninitialized in this function [-Wmaybe-uninitialized]
         __pyx_v_next_random = __pyx_v_5utils_18training_sdg_inner_fast_o1(__pyx_v_negative, __pyx_v_table, __pyx_v_table_len, __pyx_v_node_embedding, __pyx_v_node_embedding, __pyx_v_size, (__pyx_v_indexes[1]), (__pyx_v_indexes[0]), __pyx_v__lr, __pyx_v_work, __pyx_v_next_random);
                               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
utils/training_sdg_inner.c:4954:31: warning: ‘__pyx_v_indexes[1]’ may be used uninitialized in this function [-Wmaybe-uninitialized]
creating build/lib.linux-x86_64-3.6
creating build/lib.linux-x86_64-3.6/utils
gcc -pthread -shared -L/home/tim/miniconda3/envs/ComE/lib -Wl,-rpath=/home/tim/miniconda3/envs/ComE/lib,--no-as-needed build/temp.linux-x86_64-3.6/utils/training_sdg_inner.o -L/home/tim/miniconda3/envs/ComE/lib -lpython3.6m -o build/lib.linux-x86_64-3.6/utils/training_sdg_inner.cpython-36m-x86_64-linux-gnu.so
running install_lib
creating /home/tim/miniconda3/envs/ComE/lib/python3.6/site-packages/utils
copying build/lib.linux-x86_64-3.6/utils/training_sdg_inner.cpython-36m-x86_64-linux-gnu.so -> /home/tim/miniconda3/envs/ComE/lib/python3.6/site-packages/utils
running install_egg_info
Writing /home/tim/miniconda3/envs/ComE/lib/python3.6/site-packages/SDG_app-0.0.0-py3.6.egg-info

% python main.py                          
/home/tim/.pyxbld/temp.linux-x86_64-3.6/pyrex/utils/training_sdg_inner.c:475:10: fatal error: numpy/arrayobject.h: No such file or directory
 #include "numpy/arrayobject.h"
          ^~~~~~~~~~~~~~~~~~~~~
compilation terminated.
2018-11-22 18:15:17 ERROR context_embeddings.py: 18 Building module utils.training_sdg_inner failed: ["distutils.errors.CompileError: command 'gcc' failed with exit status 1\n"]
Traceback (most recent call last):
  File "/home/tim/miniconda3/envs/ComE/lib/python3.6/distutils/unixccompiler.py", line 118, in _compile
    extra_postargs)
  File "/home/tim/miniconda3/envs/ComE/lib/python3.6/distutils/ccompiler.py", line 909, in spawn
    spawn(cmd, dry_run=self.dry_run)
  File "/home/tim/miniconda3/envs/ComE/lib/python3.6/distutils/spawn.py", line 36, in spawn
    _spawn_posix(cmd, search_path, dry_run=dry_run)
  File "/home/tim/miniconda3/envs/ComE/lib/python3.6/distutils/spawn.py", line 159, in _spawn_posix
    % (cmd, exit_status))
distutils.errors.DistutilsExecError: command 'gcc' failed with exit status 1

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/tim/miniconda3/envs/ComE/lib/python3.6/site-packages/pyximport/pyximport.py", line 215, in load_module
    inplace=build_inplace, language_level=language_level)
  File "/home/tim/miniconda3/envs/ComE/lib/python3.6/site-packages/pyximport/pyximport.py", line 191, in build_module
    reload_support=pyxargs.reload_support)
  File "/home/tim/miniconda3/envs/ComE/lib/python3.6/site-packages/pyximport/pyxbuild.py", line 102, in pyx_to_dll
    dist.run_commands()
  File "/home/tim/miniconda3/envs/ComE/lib/python3.6/distutils/dist.py", line 955, in run_commands
    self.run_command(cmd)
  File "/home/tim/miniconda3/envs/ComE/lib/python3.6/distutils/dist.py", line 974, in run_command
    cmd_obj.run()
  File "/home/tim/miniconda3/envs/ComE/lib/python3.6/site-packages/Cython/Distutils/old_build_ext.py", line 185, in run
    _build_ext.build_ext.run(self)
  File "/home/tim/miniconda3/envs/ComE/lib/python3.6/distutils/command/build_ext.py", line 339, in run
    self.build_extensions()
  File "/home/tim/miniconda3/envs/ComE/lib/python3.6/site-packages/Cython/Distutils/old_build_ext.py", line 193, in build_extensions
    self.build_extension(ext)
  File "/home/tim/miniconda3/envs/ComE/lib/python3.6/distutils/command/build_ext.py", line 533, in build_extension
    depends=ext.depends)
  File "/home/tim/miniconda3/envs/ComE/lib/python3.6/distutils/ccompiler.py", line 574, in compile
    self._compile(obj, src, ext, cc_args, extra_postargs, pp_opts)
  File "/home/tim/miniconda3/envs/ComE/lib/python3.6/distutils/unixccompiler.py", line 120, in _compile
    raise CompileError(msg)
distutils.errors.CompileError: command 'gcc' failed with exit status 1

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "main.py", line 13, in <module>
    from ADSCModel.context_embeddings import Context2Vec
  File "/home/tim/Uni/HPI/workspace/ComE/ComE/ADSCModel/context_embeddings.py", line 19, in <module>
    raise e
  File "/home/tim/Uni/HPI/workspace/ComE/ComE/ADSCModel/context_embeddings.py", line 15, in <module>
    from utils.training_sdg_inner import train_o2, loss_o2, FAST_VERSION
  File "/home/tim/miniconda3/envs/ComE/lib/python3.6/site-packages/pyximport/pyximport.py", line 458, in load_module
    language_level=self.language_level)
  File "/home/tim/miniconda3/envs/ComE/lib/python3.6/site-packages/pyximport/pyximport.py", line 231, in load_module
    raise exc.with_traceback(tb)
  File "/home/tim/miniconda3/envs/ComE/lib/python3.6/site-packages/pyximport/pyximport.py", line 215, in load_module
    inplace=build_inplace, language_level=language_level)
  File "/home/tim/miniconda3/envs/ComE/lib/python3.6/site-packages/pyximport/pyximport.py", line 191, in build_module
    reload_support=pyxargs.reload_support)
  File "/home/tim/miniconda3/envs/ComE/lib/python3.6/site-packages/pyximport/pyxbuild.py", line 102, in pyx_to_dll
    dist.run_commands()
  File "/home/tim/miniconda3/envs/ComE/lib/python3.6/distutils/dist.py", line 955, in run_commands
    self.run_command(cmd)
  File "/home/tim/miniconda3/envs/ComE/lib/python3.6/distutils/dist.py", line 974, in run_command
    cmd_obj.run()
  File "/home/tim/miniconda3/envs/ComE/lib/python3.6/site-packages/Cython/Distutils/old_build_ext.py", line 185, in run
    _build_ext.build_ext.run(self)
  File "/home/tim/miniconda3/envs/ComE/lib/python3.6/distutils/command/build_ext.py", line 339, in run
    self.build_extensions()
  File "/home/tim/miniconda3/envs/ComE/lib/python3.6/site-packages/Cython/Distutils/old_build_ext.py", line 193, in build_extensions
    self.build_extension(ext)
  File "/home/tim/miniconda3/envs/ComE/lib/python3.6/distutils/command/build_ext.py", line 533, in build_extension
    depends=ext.depends)
  File "/home/tim/miniconda3/envs/ComE/lib/python3.6/distutils/ccompiler.py", line 574, in compile
    self._compile(obj, src, ext, cc_args, extra_postargs, pp_opts)
  File "/home/tim/miniconda3/envs/ComE/lib/python3.6/distutils/unixccompiler.py", line 120, in _compile
    raise CompileError(msg)
ImportError: Building module utils.training_sdg_inner failed: ["distutils.errors.CompileError: command 'gcc' failed with exit status 1\n"]

Note: I renamed the environment in env.yml to ComE and inserted import pyximport and pyximport.install() in the main.py directly after the __author__ line.

vaudaine commented 5 years ago

Hello, I successfully installed comE today.

1) Install Cython==0.25 2) In comE-master, run: 'python3 cython_utils.py build_ext' A new directory 'build' will be created. 3) Navigate the directories and find training_sdg_inner.cpython-36m-x86_64-linux-gnu.so and training_sdg_inner.o. Copy and paste both files to the comE-master/utils/ directory. 4) run: 'python3 main.py' You can also edit main.py to change the parameters at your will.

Rémi

PS : you also need to downgrade networkx to 1.11 or see pull requests

UncleLLD commented 2 years ago

https://github.com/andompesta/ComE/issues/2#issuecomment-494777883

this help me fix the problem, thanks