ImportError: No Module Named... (basics?)
A very basic question that has been confusing me. Can't seem to find any solutions online so far... I have a simple script and want to import another script I just made in the same
Solution 1:
This is because your current directory isn't on the PYTHON_PATH
, which is what import
searches when you call it. See the documentation.
If you want an immediate fix, you can use the following:
import sys, os
sys.path.append(os.path.abspath(os.path.dirname(__file__)))
This adds the directory containing the script's file to the python path.
This will only work if the directory these scripts are in is set up as a package.
Post a Comment for "ImportError: No Module Named... (basics?)"