2

So, it turned out i was missing a semi-colon from my PYTHONPATH definition. But this only got me so far. for some reason, my script did NOT work as a scheduled task (on WinXP) until I explicitly added a directory from PYTHONPATH to the top of my script.

Question is: When do I need to explicitly append something to my path and when can I simply rely on the environment variables?

Ramy
  • 20,541
  • 41
  • 103
  • 153

2 Answers2

4

Perhaps you're not running the scheduled task under the right credentials (log-in name). When you define environment variables in System Properties dialog, they can be either User-level or System-level. If you defined PYTHONPATH as User-level then your scheduled task must run as that user for it to be set properly. I believe making it System-level would mean it would apply to all users unless they have their own value defined.

Below is a screenshot showing where one sets environment variables. It's similar in both Windows XP and Windows 7. The top half of the right-hand dialog box shows the current User-level settings, and the bottom half lists all the System-level ones.

screenshot of environment variable dialog box

If PYTHONPATH appears in the list of names in the upper User-level group, you can effectively move it to the other lower one by first deleting and then adding one of the same name plus associated value to the lower System-level set. To save a little typing, you can Edit the user-level variable before you Delete it to be given a chance to first copy its current value, then Cancel-out of the operation. That way, when you make the New System-level copy you'll be able to simply paste the copied value into it.

martineau
  • 119,623
  • 25
  • 170
  • 301
  • two things: 1.) how can I tell if I've created a system-level variable. This seems to jive with what's going on but i don't see anywhere that tells me whether the variable I've set is at the system or user level. 2.)If it IS at the user level, how could i change it to the system level? – Ramy Nov 17 '10 at 21:12
  • @Ramy: I updated my answer to respond to each of your further questions. – martineau Nov 18 '10 at 10:56
0

If the other modules belongs to the same package you should be responsible to locate them if they are not stored in the conventional format (i.e. append the path with sys).

If the other modules are user-configurable then the user have to specify the installation path trough PYTHONPATH

fabrizioM
  • 46,639
  • 15
  • 102
  • 119