I’m having a bit of an issue using eclipse to run my Panda3D code. I was wondering if anybody could help me? I have two folders under my project: Models and Scenes. When loading actors in using the path ‘Models/filenamehere.egg’, it works beautifully, but whenever i do something like: file = open(“Scenes/SceneP.txt”, ‘r’) I get no such file or directory error. In the case of the open commands i use, i need to supply an absolute path. Is there any way to get relative paths like the above working in eclipse?
It should work like this. The problem is not eclipse specific and is some place else.
Any idea what might be causing the issue then?
Where is your working directory ?
What’s the result of :
C:\Documents and Settings\user.YOUR-0CDC4F5844\
C:\Documents and Settings\user.YOUR-0CDC4F5844\Scenes\SceneP.txt
The correct path though should be
C:\Documents and Settings\user.YOUR-0CDC4F5844\workspace\GamePython\Scenes\SceneP.txt
Hmmm…so how do I change the path so it’ll match the bottom properly using relative file paths?
It’s a question of how you feed your main module to python. Where is it located ? Already in GamePython ? Then how could your cwd is 2 levels higher ? Are you sure you didn’t change it in your script ?
My main.py is in the GamePython Folder as is everything else, and in no place in my code do i alter absolute paths or anything of the sort.
sys path prints this:
C:\Documents and Settings\user.YOUR-0CDC4F5844\workspace\GamePython
That’s good. Then there’s something else. Do this before anything else :
Excellent. Thanks a bunch, everything works quite well.