Re: PYTHONPATH or any other way to set seachpath (winXP) ?

2007-02-05 Thread Gabriel Genellina
En Sat, 03 Feb 2007 14:25:31 -0300, Stef Mientki  
[EMAIL PROTECTED] escribió:

 Is it possible to change the searchpath for modules on the flight,
 under winXP ?
 Most preferred is some command to extend the searchpath.
 (the environment variable PYTHONPATH needs a reboot)

PYTHONPATH is used to build the initial contents of sys.path, which is the  
actual list of directories searched. It's a standard list object so you  
can modify it easily.

-- 
Gabriel Genellina

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: PYTHONPATH or any other way to set seachpath (winXP) ?

2007-02-04 Thread Rob Wolfe
Stef Mientki [EMAIL PROTECTED] writes:

 Is it possible to change the searchpath for modules on the flight,
 under winXP ?
 Most preferred is some command to extend the searchpath.
 (the environment variable PYTHONPATH needs a reboot)

Do you mean something like that?

 import some_module
Traceback (most recent call last):
  File stdin, line 1, in ?
ImportError: No module named some_module
 import sys
 sys.path.append(..)
 import some_module

http://docs.python.org/tut/node8.html#SECTION00811

-- 
HTH,
Rob
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: PYTHONPATH or any other way to set seachpath (winXP) ?

2007-02-04 Thread Stef Mientki
 Do you mean something like that?
 
 import some_module
 Traceback (most recent call last):
   File stdin, line 1, in ?
 ImportError: No module named some_module
 import sys
 sys.path.append(..)
 import some_module
Rob,
thank you very much,
that's exactly what I want.
(Why is the obvious so often invisible to me ;-)

cheers,
Stef Mientki
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: PYTHONPATH or any other way to set seachpath (winXP) ?

2007-02-04 Thread Jussi Salmela
Stef Mientki kirjoitti:
 Is it possible to change the searchpath for modules on the flight,
 under winXP ?
What do you mean by *on the flight*: inside IDLE? using the command line?
 Most preferred is some command to extend the searchpath.
 (the environment variable PYTHONPATH needs a reboot)
 
No, it doesn't. PYTHONPATH can be updated somewhere in the environment 
options (sorry: I've got a Finnish language XP version, so I don't 
remember the exact terms) and the new path comes in effect immediately 
i.e. the launches after that see the new definition.

That way of changing the PYTHONPATH is a little difficult, though. In 
command line usage i.e. CMD.EXE I have been using these kinds of bat 
files to alternate between versions 2.4 and 2.5 of Python. (These were 
suggested earlier by someone in this group I think):
===
Py24.bat (Py25.bat has Python25 instead of Python24 in it)
===
@echo off
if .%1.==.. goto NODEV
set DEMOHOME=%1
goto CONT
:NODEV
set DEMOHOME=C:
:CONT
set PYTHONHOME=%DEMOHOME%\Python24
set PYTHONPATH=%PYTHONHOME%;
set PYTHON=%PYTHONHOME%\python.exe
set PYTHONW=%PYTHONHOME%\pythonw.exe
set PATH=%PYTHONHOME%;%PATH%

===
Py.bat (to launch Python)
===
%PYTHON% %1.py %2 %3 %4 %5 %6 %7 %8 %9

 thanks,
 Stef Mientki

HTH,
Jussi
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: PYTHONPATH or any other way to set seachpath (winXP) ?

2007-02-04 Thread Stef Mientki
Jussi Salmela wrote:
 Stef Mientki kirjoitti:
 Is it possible to change the searchpath for modules on the flight,
 under winXP ?
 What do you mean by *on the flight*: inside IDLE? using the command line?

No, I run Python, embedded from within a Delphi program.

 Most preferred is some command to extend the searchpath.
 (the environment variable PYTHONPATH needs a reboot)

 No, it doesn't. PYTHONPATH can be updated somewhere in the environment 
 options (sorry: I've got a Finnish language XP version, so I don't 
 remember the exact terms) and the new path comes in effect immediately 
 i.e. the launches after that see the new definition.
 
Through My computer | properties | advanced | Environment Variables
you have to reboot.
But as I remember well there should be a way, (through the registry or DOS-box 
?)
but I don't want to mess in the registry,
I want to keep my application portable.
But the suggestion of Rob, looks perfect.

thanks anyway,
Stef Mientki
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: PYTHONPATH or any other way to set seachpath (winXP) ?

2007-02-04 Thread Inca
 Through My computer | properties | advanced | Environment Variables
 you have to reboot.

The best overall solution is the one where you modify sys.path to add
your own custom paths, however Jussi is right in that you do not need
to reboot. You have to restart any applications that relies on using
the updated environment variables (in your case the Delphi program):

http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/environment_variables.mspx?mfr=true

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: PYTHONPATH or any other way to set seachpath (winXP) ?

2007-02-04 Thread Stef Mientki
Inca wrote:
 Through My computer | properties | advanced | Environment Variables
 you have to reboot.
 
 The best overall solution is the one where you modify sys.path to add
 your own custom paths,
I agree, specially in my situation that is the best solution.

  however Jussi is right in that you do not need
 to reboot. You have to restart any applications that relies on using
 the updated environment variables (in your case the Delphi program):
 
 http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/environment_variables.mspx?mfr=true
 
I think the problem comes from the Delphi interface,
both Idle and PyScripter reflect a change PYTHONPATH after a restart.
But my Delphi program needs a reboot :-(
I'll ask around in the Python4Delphi newsgroup.

cheers,
Stef Mientki
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: PYTHONPATH or any other way to set seachpath (winXP) ?

2007-02-04 Thread Ron Adam
Stef Mientki wrote:
 Do you mean something like that?

 import some_module
 Traceback (most recent call last):
   File stdin, line 1, in ?
 ImportError: No module named some_module
 import sys
 sys.path.append(..)
 import some_module
 Rob,
 thank you very much,
 that's exactly what I want.
 (Why is the obvious so often invisible to me ;-)
 
 cheers,
 Stef Mientki

Just a note, If you run the module from different location, it may not always 
work.

The '..' is relative to the location you are running the module from, the 
current directory, and not relative to the location of the module is at.

It won't be a problem for you if you can be sure the module is always ran from 
the location it is at.

Cheers,
Ron

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: PYTHONPATH or any other way to set seachpath (winXP) ?

2007-02-04 Thread Stef Mientki

 Just a note, If you run the module from different location, it may not 
 always work.
 
 The '..' is relative to the location you are running the module from, 
 the current directory, and not relative to the location of the module is 
 at.
thanks for the tip Ron,
I didn't realized .. was literal ;-)
so I've changed my application, so it inserts the absolute path.

cheers,
Stef
 
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: PYTHONPATH or any other way to set seachpath (winXP) ?

2007-02-03 Thread Sick Monkey

If you need to extend your PATH variable, I have used this in the past.
This should not require a reboot.
~~
def AddSysPath(new_path):
   new_path = os.path.abspath(new_path)
   do = -1
   if os.path.exists(new_path):
   do = 1
   # check against all paths currently available
   for x in sys.path:
   x = os.path.abspath(x)
   if sys.platform == 'win32':
   x = x.lower()
   if new_path in (x, x + os.sep):
   do = 0
   # add path if we don't already have it
   if do:
   sys.path.append(new_path)
   pass

   return do

On 2/3/07, Stef Mientki [EMAIL PROTECTED] wrote:


Is it possible to change the searchpath for modules on the flight,
under winXP ?
Most preferred is some command to extend the searchpath.
(the environment variable PYTHONPATH needs a reboot)

thanks,
Stef Mientki
--
http://mail.python.org/mailman/listinfo/python-list

-- 
http://mail.python.org/mailman/listinfo/python-list