facebookresearch / poincare-embeddings

PyTorch implementation of the NIPS-17 paper "Poincaré Embeddings for Learning Hierarchical Representations"

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Module not found when trying to train model

jeskreiswinkler-etsy opened this issue · comments

I am getting the following error after following the installation instructions. Could you please advice how to resolve it?

(poincare) local-poincare-embeddings $./train-mammals.sh Traceback (most recent call last): File "embed.py", line 12, in <module> from hype.adjacency_matrix_dataset import AdjacencyDataset ModuleNotFoundError: No module named 'hype.adjacency_matrix_dataset'

It's clear the issue has to do with my path, but even when I add the poincare repo to my path, if i run a python interactive window in terminal, the path doesn't update. Do you know why this might be? Should I be editting something other than PATH? online it seems like some suggest a PYTHONPATH variable but I do not have one set at the moment...

Did you run

python setup.py build_ext --inplace

As the installation instructions say?

Yes I did. Just reran it again. There are some warnings when I run it related to variable types but nothing related to paths or this module. Any plan B?

Can you copy the exact output when you run it? Do you have a adjacency_matrix_dataset.*.so file in the hype directory?

Sorry, I meant copy the output of running python setup.py build_ext --inplace

(poincare) local-poincare-embeddings $python setup.py build_ext --inplace
Compiling hype/graph_dataset.pyx because it changed.
Compiling hype/adjacency_matrix_dataset.pyx because it changed.
[1/2] Cythonizing hype/adjacency_matrix_dataset.pyx
/usr/local/lib/python3.7/site-packages/Cython/Compiler/Main.py:369: FutureWarning: Cython directive 'language_level' not set, using 2 for now (Py2). This will change in a later release! File: /Users/jeskreiswinkler/local_mods/poincare-embeddings/hype/adjacency_matrix_dataset.pyx
tree = Parsing.p_module(s, pxd, full_module_name)
[2/2] Cythonizing hype/graph_dataset.pyx
/usr/local/lib/python3.7/site-packages/Cython/Compiler/Main.py:369: FutureWarning: Cython directive 'language_level' not set, using 2 for now (Py2). This will change in a later release! File: /Users/jeskreiswinkler/local_mods/poincare-embeddings/hype/graph_dataset.pyx
tree = Parsing.p_module(s, pxd, full_module_name)
running build_ext
building 'hype.graph_dataset' extension
creating build
creating build/temp.macosx-10.14-x86_64-3.7
creating build/temp.macosx-10.14-x86_64-3.7/hype
clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/usr/include -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/System/Library/Frameworks/Tk.framework/Versions/8.5/Headers -I/usr/local/lib/python3.7/site-packages/numpy/core/include -I/usr/local/include -I/usr/local/opt/openssl@1.1/include -I/usr/local/opt/sqlite/include -I/usr/local/Cellar/python/3.7.6_1/Frameworks/Python.framework/Versions/3.7/include/python3.7m -c hype/graph_dataset.cpp -o build/temp.macosx-10.14-x86_64-3.7/hype/graph_dataset.o -stdlib=libc++
In file included from hype/graph_dataset.cpp:638:
In file included from /usr/local/lib/python3.7/site-packages/numpy/core/include/numpy/arrayobject.h:4:
In file included from /usr/local/lib/python3.7/site-packages/numpy/core/include/numpy/ndarrayobject.h:12:
In file included from /usr/local/lib/python3.7/site-packages/numpy/core/include/numpy/ndarraytypes.h:1832:
/usr/local/lib/python3.7/site-packages/numpy/core/include/numpy/npy_1_7_deprecated_api.h:17:2: warning:
"Using deprecated NumPy API, disable it with " "#define NPY_NO_DEPRECATED_API
NPY_1_7_API_VERSION" [-W#warnings]
#warning "Using deprecated NumPy API, disable it with "
^
hype/graph_dataset.cpp:5434:41: warning: comparison of integers of different signs:
'std::__1::unordered_set<long, std::__1::hash, std::__1::equal_to,
std::__1::allocator >::size_type' (aka 'unsigned long') and 'int' [-Wsign-compare]
...__pyx_v_negs.size() < ((struct __pyx_vtabstruct_4hype_13graph_dataset_BatchedDataset *)__pyx_v_self->__pyx_vtab)->_nnegatives(__pyx_v_self)...
~~~~~~~~~~~~~~~~~~~ ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2 warnings generated.
clang++ -bundle -undefined dynamic_lookup build/temp.macosx-10.14-x86_64-3.7/hype/graph_dataset.o -L/usr/local/lib -L/usr/local/opt/openssl@1.1/lib -L/usr/local/opt/sqlite/lib -o /Users/jeskreiswinkler/local_mods/poincare-embeddings/hype/graph_dataset.cpython-37m-darwin.so -stdlib=libc++
building 'hype.adjacency_matrix_dataset' extension
clang -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/usr/include -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk/System/Library/Frameworks/Tk.framework/Versions/8.5/Headers -I/usr/local/lib/python3.7/site-packages/numpy/core/include -I/usr/local/include -I/usr/local/opt/openssl@1.1/include -I/usr/local/opt/sqlite/include -I/usr/local/Cellar/python/3.7.6_1/Frameworks/Python.framework/Versions/3.7/include/python3.7m -c hype/adjacency_matrix_dataset.cpp -o build/temp.macosx-10.14-x86_64-3.7/hype/adjacency_matrix_dataset.o -stdlib=libc++
In file included from hype/adjacency_matrix_dataset.cpp:638:
In file included from /usr/local/lib/python3.7/site-packages/numpy/core/include/numpy/arrayobject.h:4:
In file included from /usr/local/lib/python3.7/site-packages/numpy/core/include/numpy/ndarrayobject.h:12:
In file included from /usr/local/lib/python3.7/site-packages/numpy/core/include/numpy/ndarraytypes.h:1832:
/usr/local/lib/python3.7/site-packages/numpy/core/include/numpy/npy_1_7_deprecated_api.h:17:2: warning:
"Using deprecated NumPy API, disable it with " "#define NPY_NO_DEPRECATED_API
NPY_1_7_API_VERSION" [-W#warnings]
#warning "Using deprecated NumPy API, disable it with "
^
hype/adjacency_matrix_dataset.cpp:5513:31: warning: comparison of integers of different signs: 'long' and
'size_t' (aka 'unsigned long') [-Wsign-compare]
__pyx_t_3 = ((__pyx_v_idx < __pyx_t_2) != 0);
~~~~~~~~~~~ ^ ~~~~~~~~~
2 warnings generated.
clang++ -bundle -undefined dynamic_lookup build/temp.macosx-10.14-x86_64-3.7/hype/adjacency_matrix_dataset.o -L/usr/local/lib -L/usr/local/opt/openssl@1.1/lib -L/usr/local/opt/sqlite/lib -o /Users/jeskreiswinkler/local_mods/poincare-embeddings/hype/adjacency_matrix_dataset.cpython-37m-darwin.so -stdlib=libc++

Can you run the following 3 commands and copy the output of each:

pwd
python -c "import hype; print(hype.__file__)"
python -c "import hype; print(dir(hype))"

Hmm, unfortunately, I'm unable to reproduce this on my end. Can you cd into the hype directory and try python -c "import adjacency_matrix_dataset; print(adjacency_matrix_dataset.__file__)". If that fails, maybe try deleting the repo and your conda environment (conda remove --name poincare --all) and re-installing from scratch.

I was about to open an issue but found this. I tried running the training shell script but hypernymysuite module was not found. I tried it with and without conda, both resulting in the same error. I could not find the module anywhere in the repository. Is there anything specific that I need to do?

Yeah, sorry you actually need to do

pip install git+https://github.com/facebookresearch/hypernymysuite.git

See #58

My bad, I did not see that issue. Yes, the training script is now working for me. Thanks for the help.

@lematt1991 First of all, thank you for the project!

Might I suggest to add this as an extra step to the README?

I faced a similar issue, thinking it had to do with my paths, until I found this discussion and solved it!

The solution was made in #70 in June, but the merge was blocked. @lematt1991 I think you just need to configure the repo to allow and then try again... the repo does not work out of box in its current state.