PATH or PYTHONPATH under Windows ???

S

Stef Mientki

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
 
G

Giuseppe Di Martino

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
 
J

Joe Salmeri

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.
 
T

Thorsten Kampe

* 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
 
S

stef

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



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
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
 
S

stef

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


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 ;-)
That's totally normal.
but why is everybody alwasy talking about the "environment variable
PYTHONPATH" ??
That's not okay. At the best it's completely useless.
???

Use common sense: reinstalling Python is likely the fastest way.
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
 
G

Giuseppe Di Martino

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
 
D

Diez B. Roggisch

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
 
S

stef

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



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.
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)
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,773
Messages
2,569,594
Members
45,122
Latest member
VinayKumarNevatia_
Top