How do you specify a certain path for the import thing to import?
import "E:\Tom's Personal Project\engine\shared.py" Any help would be appreciated :)
i tried what it said on the site but it didn't work
Traceback (most recent call last):
File "E:/Tom's Personal Project/engine/world/worldloader.py", line 6, in <module>
ImportError: No module named shared.print.newPrint
Tom's Personal Project engine world WorldLoader.py WorldLoader.ini shared __init__.py print __init__.py newPrint.py
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....
Thanks now it works!
The temporary sys.path.append() specific to your program is probably the best solution in your case.