472,131 Members | 1,719 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,131 software developers and data experts.

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
Jun 5 '07 #1
8 3363
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

Jun 5 '07 #2
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;.WS F;.WSH;

Modify it so it says:

PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WS F;.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.**************@mailbox.kun.nlwrote in message
news:90***************************@news.speedlinq. nl...
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

Jun 5 '07 #3
* 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
Jun 6 '07 #4
Giuseppe Di Martino wrote:
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
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
Giuseppe

Jun 6 '07 #5
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" ??
>
>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.
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


Thorsten
Jun 6 '07 #6
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
Jun 6 '07 #7
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
Jun 6 '07 #8
Giuseppe Di Martino wrote:
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.
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
Jun 6 '07 #9

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Pierre Rouleau | last post: by
3 posts views Thread by Stephen Ferg | last post: by
4 posts views Thread by Jesse B. | last post: by
4 posts views Thread by Alex | last post: by
reply views Thread by Michael Yanowitz | last post: by
19 posts views Thread by Ju Hui | last post: by
2 posts views Thread by Daniel Mark | last post: by
3 posts views Thread by HMS Surprise | last post: by
reply views Thread by leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.