Python Forum
Super simple import doesn't work. Please help!
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Super simple import doesn't work. Please help!
#1
(Python 3.6.5)
I've searched this forum and google as well. Lot's of seemingly related problems but nothing really quite like mine.
My problem is earth-shatteringly simple, which makes it all the more frustrating...

I got two python scripts in the same folder, like so:
C:/Projects/Interner
auxScript.py
interner.py
(nothing else in that folder)

interner.py, the "main" program contains only this:
import auxScript
auxScript.py contains only this:
def printman():
    print("Aux is here.")
When I run interner.py (from the Interner folder!), I get:
Output:
Traceback (most recent call last): File "interner.py", line 1, in <module> import auxScript ModuleNotFoundError: No module named 'auxScript'
Additional info:
1. After the error, I did:
>>> import os; print(os.listdir("."))
['auxScript.py', 'interner.py']

2. From python interactive console:
>>> import sys; print(sys.path)
['C:\\Tools\\Python\\python365\\python36.zip', 'C:\\Tools\\Python\\python365']

3. Printing system path from inside the main script (had to remove the import of auxScript)
C:\Projects\Interner>python interner.py
['C:\\Tools\\Python\\python365\\python36.zip', 'C:\\Tools\\Python\\python365']

Soooo, while all the manuals on the internet say I can just 'import auxScript' because "script's path is added to sys path", I actually can't and I can easily see that neither my present working dir nor my script's location (which happen to be the same) are added to the sys.path.

Worth mentioning I installed python by unzipping a portable version and adding the executable to the path.
Maybe my installation method was wrong?
Reply


Messages In This Thread
Super simple import doesn't work. Please help! - by Mustey - Jul-18-2018, 02:53 PM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020