Home     |     .Net Programming    |     cSharp Home    |     Sql Server Home    |     Javascript / Client Side Development     |     Ajax Programming

Ruby on Rails Development     |     Perl Programming     |     C Programming Language     |     C++ Programming     |     IT Jobs

Python Programming Language     |     Laptop Suggestions?    |     TCL Scripting     |     Fortran Programming     |     Scheme Programming Language


 
 
Cervo Technologies
The Right Source to Outsource

MS Dynamics CRM 3.0

Python Programming Language

PATH or PYTHONPATH under Windows ???


hello,

after cleaning up a PC, Python can't find any libraries anymore.
But happily I've still one PC, where Python is running perfect.
Now I always read about the environment variable "PYTHONPATH".
But on neither PC there exists a "PYTHONPATH".

On the PC that works ok,
there is the standard "PATH" environment variable,
and indeed there are all the Python Library references.

Please enlighten me.

thanks,
Stef Mientki

Il Tue, 05 Jun 2007 23:57:15 +0200, Stef Mientki ha scritto:

> hello,

> after cleaning up a PC, Python can't find any libraries anymore.
> But happily I've still one PC, where Python is running perfect.
> Now I always read about the environment variable "PYTHONPATH".
> But on neither PC there exists a "PYTHONPATH".

> On the PC that works ok,
> there is the standard "PATH" environment variable,
> and indeed there are all the Python Library references.

> Please enlighten me.

> thanks,
> Stef Mientki

Download pyrun.exe (http://developer.berlios.de/projects/pyrun) and copy
it in your Python's folder; to exec python.exe use pyrun python or to exec
script.py use pyrun python script.py

Giuseppe

Modify the PATHEXT environment variable to include .py;

For example the default one on Windows XP is:

    PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;

Modify it so it says:

    PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.py

Now you can run python programs from your cmd prompt by just typing in the
script name (with or without the .py)

Instead of adding directories to your path so that you can easily run
programs (like python)  try this instead.

Use notepad to create a file named alias.

Add lines to that file for the shortcuts you want.

For instance here is the shortcut I have for Python

p       = P:\SW\python\python.exe $*

Modify the shortcut on the start menu for the command prompt from

    %SystemRoot%\system32\cmd.exe /k doskey /macrofile=P:\SW\JoeUtil\Alias

to

    %SystemRoot%\system32\cmd.exe /k doskey
/macrofile=<FULLY_QUALIFIED_PATH>\alias

Now when you use that shortcut for the command prompt it will run doskey
which will load your alias file.

With the above setup you can just type p at the cmd prompt to get the
interactive python prompt.

Since I have two versions of python installed right now I have another alias
setup

pold    = P:\SW\python.2.4.2\python.exe $*

This allows me to compare differences between the two versions of python.

"Stef Mientki" <S.Mientki-nos@mailbox.kun.nl> wrote in message

news:90155$4665db45$d443bb3a$16812@news.speedlinq.nl...

* Stef Mientki (Tue, 05 Jun 2007 23:57:15 +0200)

> after cleaning up a PC,

Uou purposely deleted things you had no clue about?!

> Python can't find any libraries anymore.
> But happily I've still one PC, where Python is running perfect.
> Now I always read about the environment variable "PYTHONPATH".
> But on neither PC there exists a "PYTHONPATH".

That's totally normal.

> On the PC that works ok,
> there is the standard "PATH" environment variable,
> and indeed there are all the Python Library references.

That's not okay. At the best it's completely useless.

> Please enlighten me.

Use common sense: reinstalling Python is likely the fastest way.

Thorsten

I ran your program but it didn't solve the problem (running Python,
embedded in Delphi).
I'm beginning to get the feeling that Python installation is a very
complex case.
Anyway thanks.

cheers,
Stef Mientki

Thorsten Kampe wrote:
> * Stef Mientki (Tue, 05 Jun 2007 23:57:15 +0200)

>> after cleaning up a PC,

> Uou purposely deleted things you had no clue about?!

Yes,
but you should have seen what a "professional" package like LabView /
LabWindows,
all had installed on my PC ;-)

>> Python can't find any libraries anymore.
>> But happily I've still one PC, where Python is running perfect.
>> Now I always read about the environment variable "PYTHONPATH".
>> But on neither PC there exists a "PYTHONPATH".

> That's totally normal.

but why is everybody alwasy talking about the "environment variable
PYTHONPATH" ??

Yes I know,
But the point is, I want to promote Python to colleagues,
show them that it's equally well suited as MatLab,
installation of Scipy + wxPython + a few other packages is terrible
difficult.
So I can not even past the front door ;-)

Therefor I'm trying to understand the search path problem,
to make a "1-button" install (through Inno Setup),
and yesterday I was forced to try that 1-button install myself :-(

cheers,
Stef Mientki

Il Wed, 06 Jun 2007 12:01:13 +0200, stef ha scritto:

> I ran your program but it didn't solve the problem (running Python,
> embedded in Delphi).
> I'm beginning to get the feeling that Python installation is a very
> complex case.
> Anyway thanks.

In the original post you don't mention "embedded in Delphi" !
This is a different thing, the problem is that your Delphi's app relies on
a Python installation in the system and, insteed, it shoud have
on its own copy of Python, avoiding any problems.

Giuseppe

> but why is everybody alwasy talking about the "environment variable
> PYTHONPATH" ??

Because that variable can be used to additionally customize the search path.
But that doesn't imply that it is _all_ there is about python search
paths - and it would be pretty crappy if it was, because you can have
different installations of python on one machine, and having one PYTHONPATH
alone would break them, making just one run properly.

Diez

I run the same scripts and use the same libs in both plain Python and
embedded Python,
so I really don't want different installs of Python (besides it's quit
big > 100 MB)
> Giuseppe

I did some more tests, and don't know if this the minimum set,
but at least this seems to be sufficient,
both for embedded Python (without a separate Python) and plain Python,

HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment\PATH =
%PATH%
p:\python\lib\site-packages\graphviz-2.8-win32.egg\bin;
p:\python\lib\site-packages\swig-1.3.24-win32.egg;
p:\python\lib\site-packages\vtk-5.0.1-win32.egg\vtk;
P:\Python;
P:\Python\Scripts;
P:\Python\Tools\Scripts;
P:\Python;p:\python\lib\site-packages\mingw-3.4.5-win32.egg\bin;
p:\python\lib\site-packages\scite-1.73-win32.egg;

HKLM\SYSTEM\CurrentControlSet\Control\Session
Manager\Environment\PYTHONPATH =
<identical to PATH>

HKLM\SYSTEM\CurrentControlSet\Control\Session
Manager\Environment\PYTHONHOME =
P:\Python

HKLM\SYSTEM\CurrentControlSet\Control\Session
Manager\Environment\PATHEXT = %PATHEXT%
py;pyc

Reboot the system (seems to be essential)

Everything works as expected

thank you all for your suggestions.

cheers,
Stef Mientki

Add to del.icio.us | Digg this | Stumble it | Powered by Megasolutions Inc