ModuleNotFoundError only occurred in conda environment

2.9k views Asked by At

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!
1

There are 1 answers

0
tupui On BEST ANSWER

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.