Linux Python Scrapy No module named six.moves

1.7k Views Asked by At

We want to use scrapy in linux machine. We use python 2.7 version and install scrapy 1.4.0 (pip install scrapy). We add import scrapy to .py file. When we run .py file, give error like below:

File "mapper.py", line 5, in <module>
    import scrapy
  File "/usr/local/lib/python2.7/dist-packages/scrapy/__init__.py", line 27, in <module>
    from . import _monkeypatches
  File "/usr/local/lib/python2.7/dist-packages/scrapy/_monkeypatches.py", line 2, in <module>
    from six.moves import copyreg
ImportError: No module named **six.moves**

We've searched this issue but can not get any answers. How can we solve this issue ? Thanks.

2

There are 2 best solutions below

0
On

Finally we found answer like below:

import os, imp
def load_src(name, fpath):
    import os, imp
    return imp.load_source(name, os.path.join(os.path.dirname(__file__), fpath))
load_src("six", "./six.py")

We import six.py from our own path then can use it finally. Actually it is a workaround solution, I think the main problem about python environment in linux server. But in this case we can not access linux machine and lots of python version installed so python's own library six.py somehow couldn't be found. So we use this solution and it worked.

0
On

Please install six module if you have not installed yet.

Install cmd: pip install six and than import using: import six

I was getting same error and mine was fixed.