Take a look at this to read more about Python modules and packages: http://docs.python.org/2/tutorial/modules.html
Turn your python-script-containing folder into a python package by adding __init__.py file to it. So, in your case, the directory structure should resemble this:
PYTHONPATH
- ScrapyingProject
- __init__.py
- script.py
Now, in this scheme, ScrappyProject becomes your python-package. Any .py file inside the folder becomes a python module. You can import a python module by dot-expanded python path starting PYTHONPATH. Something like,
from ScrapyingProject.script import XXXSpider
Same logic can be extended by nesting multiple packages inside each other. A nested package, for example looks like
PYTHONPATH
- ScrapyingProject2
- __init__.py
- ScrapyingProject2
- __init__.py
- script.py
Now, a package-nested script.py can be imported as
from ScrapyingProject2.ScrapyingProject2 import script
Or even
from ScrapyingProject2.ScrapyingProject2.script import XXXSpider
(Assuming you have defined class XXXSpider inside script.py)
spidersis aspider.pyfile. Move the file or, wouldn't an implementetion ofif __name__ == "__main__": main()help out here?