473,721 Members | 2,235 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 3508
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;.E XE;.BAT;.CMD;.V BS;.VBE;.JS;.JS E;.WSF;.WSH;

Modify it so it says:

PATHEXT=.COM;.E XE;.BAT;.CMD;.V BS;.VBE;.JS;.JS E;.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\py thon.exe $*

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

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

to

%SystemRoot%\sy stem32\cmd.exe /k doskey
/macrofile=<FULL Y_QUALIFIED_PAT H>\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.speed linq.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 "profession al" 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 "environmen t 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 "environmen t 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\Cur rentControlSet\ Control\Session Manager\Environ ment\PATH =
%PATH%
p:\python\lib\s ite-packages\graphv iz-2.8-win32.egg\bin;
p:\python\lib\s ite-packages\swig-1.3.24-win32.egg;
p:\python\lib\s ite-packages\vtk-5.0.1-win32.egg\vtk;
P:\Python;
P:\Python\Scrip ts;
P:\Python\Tools \Scripts;
P:\Python;p:\py thon\lib\site-packages\mingw-3.4.5-win32.egg\bin;
p:\python\lib\s ite-packages\scite-1.73-win32.egg;

HKLM\SYSTEM\Cur rentControlSet\ Control\Session
Manager\Environ ment\PYTHONPATH =
<identical to PATH>

HKLM\SYSTEM\Cur rentControlSet\ Control\Session
Manager\Environ ment\PYTHONHOME =
P:\Python

HKLM\SYSTEM\Cur rentControlSet\ Control\Session
Manager\Environ ment\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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
8590
by: Pierre Rouleau | last post by:
I can't remember where/how sys.path is set (aside from the automatically loaded site.py) and i get a strange entry in it. Can anyone remind me where/how to control sys.path on a Win32 machine (i'm running XP on the one where the issue arises). I can't figure out why the 'C:\WINDOWS\System32\python23.zip' entry is inside sys.path. That file/dir does not exist on the disk. Could a failing (crashing) Pythonwin installation caused that? ...
3
9729
by: Stephen Ferg | last post by:
I need a little help here. I'm developing some introductory material on Python for non-programmers. The first draft includes this statement. Is this correct? ----------------------------------------------------------------- When loading modules, Python looks for modules in the following places in the following order:
4
1982
by: Jesse B. | last post by:
I have just begun to learn python using o'reilly's Learning Python, and in chapter 3 it talks about importing modules. It has me make modules to practice using the 'import' and 'from' statements from the python command line. I don't know what directory to save these files in because I'm not sure what directories 'import' is looking in to find modules. I've done some google searches trying to find out where the 'import' search path is,...
4
2858
by: Alex | last post by:
Rossum's tutorial states "Actually, modules are searched in the list of directories given by the variable sys.path which is initialized from the directory containing the input script (or the current directory)" I'm running Python standard installation (ver 2.4) on Windows XP. Where can I find the "input script" where the sys.path is defined? Alex
0
1755
by: Michael Yanowitz | last post by:
Hello: Someone on my team tried out installing my Python code and found that setting PYTHONPATH does not work, but setting PATH environment variable works the way PYTHONPATH should. Is that how it supposed to be, or is that a bug or feature? -----Original Message----- (parts deleted) Subject: question on Python for windows
19
40710
by: Ju Hui | last post by:
is python search module by paths in sys.path? how to change it manuallly?
2
4784
by: Daniel Mark | last post by:
Hello all: I installed IPython on my XP machine today and find that my sys.path has been changed as follows:
17
5409
by: mohan | last post by:
Hi Guys, I've been using the following IDE, "Pythonwin - Python IDE and GUI Framework for Windows. Copyright 1994-2001 Mark Hammond " With respect to my work, I had created my own modules (.py files) in drives and folders other than the python root. I know that if I need to
3
3903
by: HMS Surprise | last post by:
Is sys.path setup differnently in jython vs python? I have environment variables pythonpath and jythonpath set to include C:\python22 but the initial printout indicates it is being ignored. Also when I used sys.path.extend, the added pathname shows up as a series of single characters. Have I misused .extend? Thanks, jh
0
8840
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9367
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9215
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9131
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
5981
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4484
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3189
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2576
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2130
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.