Welcome Guest ( Log In | Register )

Outline · [ Standard ] · Linear+

 cannot brain python pathing system

views
     
TSFLampard
post Jul 24 2023, 02:45 PM, updated 3y ago

On my way
****
Junior Member
590 posts

Joined: Jun 2008
i created a script that imports from another module


script.py
/folder1/module.py

script.py imports module.py

so in my script.py i put

from folder1.module import module (the thing i want to import)


then i cmd and cd to the directory and python script.py

no problem so far, works perfectly

but when i cmd and straight up put python f:dir1/dir2/dir3/script.py

suddenly its not able to find module.py and it tells me "module not found"

confused.gif confused.gif confused.gif

This post has been edited by FLampard: Jul 24 2023, 02:48 PM
angch
post Jul 24 2023, 02:57 PM

On my way
****
Junior Member
636 posts

Joined: Jul 2006
Your current work directory (CWD) is different.

Anyway, use

SET PYTHONPATH=”path/to/directory”

etc to set the absolute path to your module to quickfix.

 

Change to:
| Lo-Fi Version
0.0130sec    0.36    5 queries    GZIP Disabled
Time is now: 24th December 2025 - 03:43 AM