1

I usually use conda environments for my developing, but I faced strange problems in conda env. I cloned this python repository. Then, I tried to run a example, but it failed ModuleNotFoundError even there is exactly parlai directory.

(torch) $ which python
/Users/jef/anaconda/envs/torch/bin/python
(torch) $ python -V
Python 3.6.1 :: Continuum Analytics, Inc.
(torch) $ python examples/train_model.py -m drqa -t squad -bs 32 -mf /tmp/model_drqa
Traceback (most recent call last):
  File "examples/train_model.py", line 26, in <module>
    from parlai.core.agents import create_agent
ModuleNotFoundError: No module named 'parlai'

But if I do not use conda env, I could succeed to run the code on same directory. What is happened in my environment?

$ which python        
/Users/jef/anaconda/bin/python
$ python -V          
Python 3.6.1 :: Anaconda 4.4.0 (x86_64)
$ python examples/train_model.py -m drqa -t squad -bs 32 -mf /tmp/model_drqa
// its working!
Alex Bravo
  • 1,601
  • 2
  • 24
  • 40
jef
  • 3,890
  • 10
  • 42
  • 76
  • Did you install the module to make it available to your python path? – tupui Sep 12 '17 at 19:54
  • Do you mean the module is `parlai`? Do I need to do something? Without conda env, I do nothing. But it is working. – jef Sep 12 '17 at 19:59
  • 1
    You need to go to the downloaded folder and type: `python setup.py install`. This will install parlai into your environment. I suppose this is working outside the env because you have something in your path that link to the folder you put parlai in. If this solve the issue I will create an answer. – tupui Sep 12 '17 at 20:00
  • Exactly you are right. It was just a mistake of me, not conda. – jef Sep 12 '17 at 20:11

1 Answers1

2

Your package has not been installed.

Go to the downloaded folder and type:

python setup.py install

This will install parlai into your environment and you can safely delete the folder.

I suppose this is working outside the env because you have something in your path that link to the folder you put parlai in.

tupui
  • 5,738
  • 3
  • 31
  • 52