[Sovled] Pytorch-example openmt, ImportError: No module named utils.rnn


Environment: python2.7; OS: ArchLinux; PyTorch_version:0.1.9_2.

$ python preprocess.py -train_src data/src-train.txt -train_tgt data/tgt-train.txt -valid_src data/src-val.txt -valid_tgt data/tgt-val.txt -save_data data/demo
Traceback (most recent call last):
File “preprocess.py”, line 1, in
import onmt
File “/home/zeng/opensource/OpenNMT-py/onmt/init.py”, line 2, in
import onmt.Models
File “/home/zeng/opensource/OpenNMT-py/onmt/Models.py”, line 5, in
from torch.nn.utils.rnn import pad_packed_sequence as unpack
ImportError: No module named utils.rnn

what cause this problem and how to solve this problem?


uninstall the pytorch and reinstall with the latest version 0.10.1

the whl links depend on what you’ve installed before.

pip uninstall http://download.pytorch.org/whl/cu80/torch-0.1.9.post2-cp27-none-linux_x86_64.whl 
pip install http://download.pytorch.org/whl/cu80/torch-0.1.10.post2-cp27-none-linux_x86_64.whl