How do you specify a certain path for the import thing to import?

such as import "E:\Tom's Personal Project\engine\shared.py" Any help would be appreciated :)

Refer here for details on how to make a "Package" taking advantage of __init__.py files... should get you going

i tried what it said on the site but it didn't work
error:
Traceback (most recent call last):
File "E:/Tom's Personal Project/engine/world/worldloader.py", line 6, in <module>
import shared.print.newPrint
ImportError: No module named shared.print.newPrint

folders:

Tom's Personal Project   
    engine
        world
            WorldLoader.py
            WorldLoader.ini
        shared
            __init__.py
            print
                __init__.py
                newPrint.py

my code:

import shared.print.newPrint

Any help would be apprecieted :)

Where are you running your script from? Try os.getcwd() at the beginning of your script to make sure you're actually in the TPP/engine directory.

i am running the worldloader.py file

Try os.getcwd() at the beginning of your script to make sure you're actually in the TPP/engine directory.

Unless you're actually running the script from within the TPP/engine directory you'll need to add it to your path. You can do that at the beginning of your script like so:

import sys

sys.path.append('/home/TPP/engine')
# Rest of your code....
Comments
thanks for a good solution
This question has already been answered. Start a new discussion instead.