clab / dynet

DyNet: The Dynamic Neural Network Toolkit
Apache License 2.0
3.41k stars 707 forks source link

"ImportError: No module named dynet_config" after manual install #820

Closed pmichel31415 closed 6 years ago

pmichel31415 commented 6 years ago

I got an error after updating dynet (after a while) to this commit d413836cd78bf16997942baadea71b5a387fc6d1

The message error looks like this:

  File "/projects/tir1/users/pmichel1/multi-speak/helpers.py", line 6, in <module>
    import dynet as dy
  File "build/bdist.linux-x86_64/egg/dynet.py", line 3, in <module>
ImportError: No module named dynet_config

I've verified and the file dynet_config.py is in the dynet/build/python folder.

For information, here's how my build script looks like:

# Go to dynet directory
cd ~/wd/dynet
# Use master branch if nothing specified
BRANCH=${1:-master}
# Just in case
git stash
git checkout $BRANCH
git pull origin $BRANCH
# This fixes a compile bug I had
sed -e "s/-march=native//g" -i.backup CMakeLists.txt
# This enables CUDA tensor contraction (makes compilation slightly slower)
sed -e "s/#define DYNET_SKIP_CUDA_CONTRACTIONS//g" -i.backup dynet/nodes-contract.cc
# Go to build directory
cd build
# Cmake (boost is probably superfluous now)
cmake .. -DEIGEN3_INCLUDE_DIR=[...] -DPYTHON=[...] -DBACKEND=cuda -DCUDNN_ROOT=[...] 
# Compile with 10 cores
make -j 10
# Compile the python module
cd python
python setup.py install --user
neubig commented 6 years ago

Sorry, I'm having trouble reproducing this. Does it break when exactly following the manual installation instructions?

pmichel31415 commented 6 years ago

My bad, I hadn't noticed the build instructions had changed.

Changing the last line for

python ../../setup.py build --build-dir=.. --skip-build install

fixed it

xunzhang commented 6 years ago

I think the problem might happen due to the CMake cache. The latest repo has removed setup.py so you can't have it in build/python folder. Please try to create another folder to try it again?

cd build_latest;
...
python ../setup.py install --skip-build --user