I don't want to save all of my python files in the default directory, but if I save them elsewhere, python can't find the path to any modules I might be using. How can I change this to work?
Jump to Post
An even easier workaround for being able to import modules from ANY directory is to modify the sys.path variable at run time. So at the beginning of your code do something like this:
import os,sys sys.path.append('/path/to_my/module') import my_custom_module
And if you're working with a hard-coded windows path …
All 6 Replies
Be a part of the DaniWeb community
We're a friendly, industry-focused community of 1.20 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.