0

I have a directory called "code". Within that directory I have to sub directories:

lib: Holds a python module I've created

src: Holds the python source code calling the module.

When I try to run the code, the import statement is not seeing the module in a separate folder. How do I make the two files interact without changing directories?

keelsinit
  • 33
  • 5
  • Possible duplicate of [How to import a module given the full path?](https://stackoverflow.com/questions/67631/how-to-import-a-module-given-the-full-path) – Galen Nov 30 '17 at 01:54
  • Possible duplicate of [Importing files from different folder](https://stackoverflow.com/questions/4383571/importing-files-from-different-folder) – sam-pyt Nov 30 '17 at 01:58
  • Suggest look up the differences between Python [modules](https://docs.python.org/2/tutorial/modules.html) and [packages](https://docs.python.org/2/tutorial/modules.html#packages). In general packages require an `__init__.py` file and go in sub-folder in the same place as the script(s) calling them. A module is just a single file containing Python definitions and statements - also in the same folder as the script that is importing it. – Bill Nov 30 '17 at 02:07

1 Answers1

0

Trying this, from ../target_directory.library import module. ../ means going up in directory depth.

I hope it helps.

Byeongguk Gong
  • 113
  • 1
  • 9