0

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.

eLRuLL
  • 18,488
  • 9
  • 73
  • 99
slnkykrn
  • 71
  • 9
  • You probably should `pip install six`. – Willem Van Onsem Dec 18 '17 at 17:54
  • We tried it already it didn't worked. six is already installed as six-1.11.0 and we have six.py. thanks anyway. – slnkykrn Dec 18 '17 at 18:03
  • if you have own file `six.py` then `import six` load your file instead expected module and it can't find `moves` in your file. Change name from `six.py` to different one. – furas Dec 18 '17 at 18:31
  • if you have own file `six.py` then `import six` load your file instead expected module and it can't find `moves` in your file. Change name from `six.py` to different one. BTW: you can try `import six ; print( six.__file__ )` to see which file you import. – furas Dec 18 '17 at 18:32
  • from six.moves import copyreg used in scrapy's _monkeypatches.py file so I can't change it manually and we didn't write it. I mean by six.py , six lib is installed by python framework. but still got this error : "No module named **six.moves**", Why ? – slnkykrn Dec 18 '17 at 19:01

2 Answers2

0

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.

slnkykrn
  • 71
  • 9
0

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.