The manual only tells you to type
ppython filename.py
which is only true if all your paths are automatically set (this should happen at installation). Youâre actually expected to know how to navigate with a command prompt to successfully use this and other of Pandaâs command line tools.
[size=150]Hereâs a quick HowTo for the windows command shell:[/size]
[color=darkblue]As example Iâll use ppython.exe here, but this HowTo is very usable for many other programs as well. See HERE for a list of executables whipped with Panda. Additional info on this topic at the end of this post.
Introduction
A command shell is mainly meant for running programs. And except the programs you know, e.g. those you usually double-click like Firefox and Minesweeper, you can use a few more. Some of them donât even open any new windows, but are run inside that blackânâwhite window. Then there are some commands that are shipped with Windows extra for command shell use only, like âcdâ or âhelpâ (there are many of those). There are others, but you wonât need too many here. Search the web for âwindows command promptâ or something similar if youâre curious.
You start programs in the command shell by simply typing their names, or better said, the names of the executable files (ending with .exe most often), followed by Enter.
Current working directory
In the command prompt shell you always are in a certain folder (same as in folder explorer). Commands you type are expected to be either in the current working directory or in the windows folder. Third case are the built-in commands of the shell, which you can use from any directory.
Use the built-in command âcdâ, which stands for âchange directoryâ to navigate to the directory that holds the application you want to start. In our case âppythonâ, which most probably lies somewhere in âC:\Panda3d-1.7.1\pythonâ or so.
In that particular case youâd have to type
cd C:\Panda3d-1.7.1\python
to get there.
The current directory you are in should be shown in the prompt meanwhile. A prompt is the short text that shows up in front of your blinking text-cursor, by the way.
While being in the directory that holds âppython.exeâ, you can simply type âppython.exeâ to start that program (most probably you can omit the .exe extension, not sure here).
Ok, now the interactive Python console runs, but how to load your script now you might ask. Before we get there, let me explain two other things.
Relative and absolute paths
Above I said that the application you start is expected to be in the current directory. This is not the whole truth. Typing a file name tells the shell that the program is to be found relative to current directory. Itâs the same as â.\ppython.exeâ, while â.â (a dot) stands for the current directory youâre in. Alternatively you can extend that relative path. Beside the dot (â.â), the windows shell also understands double dot (ââŚâ), which stands symbolicaly for the parent directory. Letâs say youâre in the directory âC:\Program Files\Adobeâ and type ââŚ\something.exeâ. In this case the shell first goes to the parent directory, which is âC:\Program Filesâ and looks for the invoked program there.
You surely notice that this kind of command invocation is depending in the current directory and it can take long to type all those pathways. This is where we introduce âabsolute pathsâ. Instead of telling the shell where a program is as seen from the working directory, we can simply tell the way as seen from the root, which is a device name. Hereâs an example invoking ppython.exe independent of your working directory: âC:\Panda3d-1.7.1\python\ppython.exeâ.
Type that (without quotes), press enter, and you should be there the quick way.
Hereâs a small comparison of four different ways to actually achieve the same:
cd C:\Panda3d-1.7.1\python
ppython.exe
C:\Panda3d-1.7.1\python\ppython.exe
Assuming youâre in C:\Users\yourname:
cd ..\..\Panda3d-1.7.1\python
ppython.exe
..\..\Panda3d-1.7.1\python\ppython.exe
Command line arguments
The second thing that needs to be mentioned is command parameters. You already saw with the command âcdâ that it expects something after a space - a path in this case.
Many commands/programs expect such arguments, which often control a program. To know what command line arguments are allowed, most programs have a default argument like â/?â or â-helpâ which shows all others.
Example:
cd /?
This line shows you a text explaining what you can do with the âcdâ command and how to use it.
The program âppython.exeâ expects a python script name (with path, to be precise) as optional argument. If given, it will start that script immadiately.
So to start your script from Desktop you could theoretically use something like this:
(Assuming your current working directory is âC:\Users\Yournameâ)
C:\Panda3d-1.7.1\python\ppython.exe Desktop\yourscript.py
About PYTHONPATH
ppython.exe and python.exe are special cases, because you can start those from any directory. If your installation went all okay, you should be able to omit the
cd C:\Panda3d-1.7.1\python
and start ppython.exe directly - like the manual describes it:
ppython.exe
Other programs shipped with Panda3D like multify.exe, egg2bam.exe and many more (see HERE) need to be started as described in the HowTo above. Most of the applications from the list take â-helpâ as argument. Use it to view detailed informations on how to actually use those treasures.
Hope this clarifies some confusion around how to use ppython and other Panda tools. Feel free to comment and criticize.