Philip
Philip

Reputation: 1

Atom 'script' package gives me ModuleNotFoundError with Python

My folder layout is the following:

folder

config.py

mainScript.py

Inside the mainScript.py file i run the following line:

from config import a, b, c

When I run mainScript.py with the Atom package script Then I get the following error:

Traceback (most recent call last): File "/var/folders/3q/ytqgpk6d7bl69td5z2jxqpfm0000gn/T/atom_script_tempfiles/beda7210-249b-11eb-97fc-47e8e768ffb0", line 12, in from config import a, b, c ModuleNotFoundError: No module named 'config'

However, when I run it in my regular macOS terminal it runs properly. Both the terminal and Atom Script are running python3.

Why is it not properly identifying the location of the config.py file? How do I get it to import it correctly.

Upvotes: 0

Views: 79

Answers (1)

Divyessh
Divyessh

Reputation: 2721

Always use it like this:

from .config import a, b, c

Upvotes: 0

Related Questions