0

1、python3 program, how to import modules from different directories
2、How do I get path information of scrapy
enter image description here
3、from RUGplatform.custom_module.rule_module import CrawlRule, ParserRule
ImportError: No module named 'RUGplatform'

LWX
  • 37
  • 6
  • duplicate question, please refer below post. [Post](https://stackoverflow.com/questions/67631/how-to-import-a-module-given-the-full-path) – jits_on_moon Jul 12 '18 at 02:57
  • Thank you,but my question may be different,I want to know what the framework does – LWX Jul 12 '18 at 03:24

1 Answers1

0

my solution:

import os
import sys
sys.path.append('/'.join(os.path.split(os.path.realpath(__file__))[0].split('/')[0:-2]))<br>
from RUGplatform.custom_module.rule_module import CrawlRule, ParserRule

Is there a more elegant solution? For example, the solution from scrapy framework

LWX
  • 37
  • 6