By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
431,990 Members | 1,710 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 431,990 IT Pros & Developers. It's quick & easy.

PATH or PYTHONPATH under Windows ???

P: n/a
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
Share this Question
Share on Google+
8 Replies


P: n/a
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

P: n/a
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

P: n/a
* 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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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.