1

For sake of organization, I've placed all my custom libraries into a subdirectory. When I run my script file in the spyder IDE, it imports everything as intended, and runs smoothly, but when I execute the script from shell, it fails to import. (I have created an __init__.py file in the modules/ directory).

Also, this is being run on Linux.

Here is my code:

import os
dirpath = os.path.dirname(__file__)
sys.path.append('{}/modules/'.format(dirpath))

#custom libraries in dirpath/modules/
import data_pull
import features
import create_listings

example = data_pull.mp(pool)
data = features.generate(example)

Shell output:
Traceback (most recent call last): File "data_manager.py", line 15, in import data_pull ModuleNotFoundError: No module named 'data_pull'

IanT
  • 79
  • 1
  • 5
  • Possible duplicate of [How do I get the path of the current executed file in Python?](https://stackoverflow.com/questions/2632199/how-do-i-get-the-path-of-the-current-executed-file-in-python) – Triggernometry Oct 09 '18 at 20:17
  • "No Module named" error shows that you have not installed the package. Try to activate the environment in which you have installed the package. (If you have a separate virtualenv) – Naveen Oct 09 '18 at 20:23

0 Answers0