472,959 Members | 1,561 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

how to clean sys.path

Hi all,

when I do >>>sys.path in IDLE (winXP), i get a horrendously long list of
paths, paths I may have used during a lot of trials and errors. How can I
clean up sys.path? I mean, trim it of unnecessary paths?

So far, I know only the command >>>sys.path.append(r'c:....etc...'), but how
to delete or insert at the beginning of the list, I know not.

Thanks,

siggi
Jan 9 '07 #1
7 12358
>
So far, I know only the command >>>sys.path.append(r'c:....etc...'), but how
to delete or insert at the beginning of the list, I know not.
You can delete a slice. For example,

del sys.path[2:5]

More about slicing: http://docs.python.org/ref/slicings.html
sys.path is a regular list. List methods:
http://docs.python.org/tut/node7.html

Best,

Laszlo

Jan 9 '07 #2
Thank you Laszlo!

Take care,

siggi

"Laszlo Nagy" <ga*****@designaproduct.bizschrieb im Newsbeitrag
news:ma***************************************@pyt hon.org...
>
>>
So far, I know only the command >>>sys.path.append(r'c:....etc...'), but
how to delete or insert at the beginning of the list, I know not.
You can delete a slice. For example,

del sys.path[2:5]

More about slicing: http://docs.python.org/ref/slicings.html
sys.path is a regular list. List methods:
http://docs.python.org/tut/node7.html

Best,

Laszlo

Jan 10 '07 #3
"siggi" <sm***********@yahoo.comwrote:
>
when I do >>>sys.path in IDLE (winXP), i get a horrendously long list of
paths, paths I may have used during a lot of trials and errors. How can I
clean up sys.path? I mean, trim it of unnecessary paths?
What do mean by "used during a lot of trials and errors"? sys.path is
recreated from scratch every time Python starts. It doesn't accumulate
over time, other than from new packages that you install.
--
Tim Roberts, ti**@probo.com
Providenza & Boekelheide, Inc.
Jan 11 '07 #4
"Tim Roberts" wrote:
>>
when I do >>>sys.path in IDLE (winXP), i get a horrendously long list of
paths, paths I may have used during a lot of trials and errors. How can I
clean up sys.path? I mean, trim it of unnecessary paths?

What do mean by "used during a lot of trials and errors"? sys.path is
recreated from scratch every time Python starts. It doesn't accumulate
over time, other than from new packages that you install.
--
Tim Roberts, ti**@probo.com
Providenza & Boekelheide, Inc.

Sorry Tim, my statement was not correct, due to my inexperience with Python.
And sorry, too, for my somewhat lengthy reply:
After having had inspected my current sys.path...

['C:\\Documents and Settings\\User\\My Documents\\My Python files',
'C:\\Documents and Settings\\User\\My Documents\\Python25\\Lib\\idlelib',
'C:\\Documents and Settings\\User\\My Documents\\Python25\\python25.zip',
'C:\\Documents and Settings\\User\\My Documents\\Python25\\DLLs',
'C:\\Documents and Settings\\User\\My Documents\\Python25\\lib',
'C:\\Documents and Settings\\User\\My Documents\\Python25\\lib\\plat-win',
'C:\\Documents and Settings\\User\\My Documents\\Python25\\lib\\lib-tk',
'C:\\Documents and Settings\\User\\My Documents\\Python25', 'C:\\Documents
and Settings\\User\\My Documents\\Python25\\lib\\site-packages',
'C:\\Documents and Settings\\User\\My
Documents\\Python25\\lib\\site-packages\\PIL', 'C:\\Documents and
Settings\\User\\My Documents\\Python25\\lib\\site-packages\\win32',
'C:\\Documents and Settings\\User\\My
Documents\\Python25\\lib\\site-packages\\win32\\lib', 'C:\\Documents and
Settings\\User\\My Documents\\Python25\\lib\\site-packages\\Pythonwin',
'C:\\Documents and Settings\\User\\My
Documents\\Python25\\lib\\site-packages\\wx-2.8-msw-ansi']

or in plain DOS:

C:\Documents and Settings\User\My Documents\My Python files
C:\Documents and Settings\User\My Documents\Python25\Lib\idlelib
C:\Documents and Settings\User\My Documents\Python25\python25.zip
C:\Documents and Settings\User\My Documents\Python25\DLLs
C:\Documents and Settings\User\My Documents\Python25\lib
C:\Documents and Settings\User\My Documents\Python25\lib\plat-win
C:\Documents and Settings\User\My Documents\Python25\lib\lib-tk
C:\Documents and Settings\User\My Documents\Python25
C:\Documents and Settings\User\My Documents\Python25\lib\site-packages
C:\Documents and Settings\User\My Documents\Python25\lib\site-packages\PIL
C:\Documents and Settings\User\My Documents\Python25\lib\site-packages\win32
C:\Documents and Settings\User\My
Documents\Python25\lib\site-packages\win32\lib
C:\Documents and Settings\User\My
Documents\Python25\lib\site-packages\Pythonwin
C:\Documents and Settings\User\My
Documents\Python25\lib\site-packages\wx-2.8-msw-ansi

....it just looked horrible to me at first sight!

If I interpret your explanation correctly, all these paths are necessary,
and not relics of previous installations and deinstallations.

What puzzles me, though, is, that e.g., when I run the wxPython application
"AnalogClock.py" with IDLE or in the command line , this works only in the
directory "...\My Python files\wxDemos\" . This directory contains all files
and folders from the original "\wx-2.8-msw-ansi\demos\").

When I copy AnalogClock.py to ...\My Python Files\ , nothing happens after
running it with IDLE or in the command line.
Appending 'C:\Documents and Settings\User\My Documents\My Python
files\wxDemos ' to the sys.path does not help either.

Thinking that I am clever, I changed my sys.path with sclicing and
concatenation such that my sys.path starts with

'C:\Documents and Settings\User\My Documents\My Python files', 'C:\Documents
and Settings\User\My Documents\My Python files\wxDemos'. Now \wxDemos\ is
being searched very early.

.... no way! After running AnalogClock.py again, this error message appears:

------------------------------------------
Traceback (most recent call last):
File "C:\Documents and Settings\My Documents\My Python
files\wxAnalogClock.py", line 14, in <module>
import wx
ImportError: No module named wx.
------------------------------------------

Very strange! Because all this wx stuff IS IN the directory 'C:\Documents
and Settings\User\My Documents\My Python files\wxDemos'. And AnalogClock.py
does work when residing in that directory.

Can you help me again?

Thanks,

siggi

P.S. On another PC where the python program is in c:\programs\python25\,
same as above!


Jan 11 '07 #5
"siggi" <sm***********@yahoo.comwrote:
>
or in plain DOS:

C:\Documents and Settings\User\My Documents\My Python files
C:\Documents and Settings\User\My Documents\Python25\Lib\idlelib
C:\Documents and Settings\User\My Documents\Python25\python25.zip
C:\Documents and Settings\User\My Documents\Python25\DLLs
C:\Documents and Settings\User\My Documents\Python25\lib
C:\Documents and Settings\User\My Documents\Python25\lib\plat-win
C:\Documents and Settings\User\My Documents\Python25\lib\lib-tk
C:\Documents and Settings\User\My Documents\Python25
C:\Documents and Settings\User\My Documents\Python25\lib\site-packages
C:\Documents and Settings\User\My Documents\Python25\lib\site-packages\PIL
C:\Documents and Settings\User\My Documents\Python25\lib\site-packages\win32
C:\Documents and Settings\User\My
Documents\Python25\lib\site-packages\win32\lib
C:\Documents and Settings\User\My
Documents\Python25\lib\site-packages\Pythonwin
C:\Documents and Settings\User\My
Documents\Python25\lib\site-packages\wx-2.8-msw-ansi

...it just looked horrible to me at first sight!
It looks horrible to me, too. That's why I install applications like that
in "\Apps" instead of a document off of Documents and setings. This looks
much better:

C:\Documents and Settings\User\My Documents\My Python files
C:\Apps\Python25\Lib\idlelib
C:\Apps\Python25\python25.zip
C:\Apps\Python25\DLLs
C:\Apps\Python25\lib
C:\Apps\Python25\lib\plat-win
C:\Apps\Python25\lib\lib-tk
C:\Apps\Python25
C:\Apps\Python25\lib\site-packages
C:\Apps\Python25\lib\site-packages\PIL
C:\Apps\Python25\lib\site-packages\win32
C:\Apps\Python25\lib\site-packages\win32\lib
C:\Apps\Python25\lib\site-packages\Pythonwin
C:\Apps\Python25\lib\site-packages\wx-2.8-msw-ansi

Searching these doesn't really take very long. Remember that it doesn't
have to read all the files -- it only has to read the directories.
>'C:\Documents and Settings\User\My Documents\My Python files', 'C:\Documents
and Settings\User\My Documents\My Python files\wxDemos'. Now \wxDemos\ is
being searched very early.

... no way! After running AnalogClock.py again, this error message appears:

------------------------------------------
Traceback (most recent call last):
File "C:\Documents and Settings\My Documents\My Python
files\wxAnalogClock.py", line 14, in <module>
import wx
ImportError: No module named wx.
------------------------------------------

Very strange! Because all this wx stuff IS IN the directory 'C:\Documents
and Settings\User\My Documents\My Python files\wxDemos'. And AnalogClock.py
does work when residing in that directory.
wxDemos contains the demos. The "wx" module lives in
site-packages\wx-2.8-msw-ansi. Did you leave that in?
--
Tim Roberts, ti**@probo.com
Providenza & Boekelheide, Inc.
Jan 13 '07 #6

"Tim Roberts" wrote:
>wxDemos contains the demos. The "wx" module lives in
site-packages\wx-2.8-msw-ansi. Did you leave that in?
Yes! Even on this computer I am writing now with - where the whole Python
programs stuff is in a programs folder, such as

C:\Programs\Python25\Lib\site-packages\wx-2.8-msw-ansi

- it is the same problem!

"siggi" <sm***********@yahoo.comwrote:
>>
or in plain DOS:

C:\Documents and Settings\User\My Documents\My Python files
C:\Documents and Settings\User\My Documents\Python25\Lib\idlelib
C:\Documents and Settings\User\My Documents\Python25\python25.zip
C:\Documents and Settings\User\My Documents\Python25\DLLs
C:\Documents and Settings\User\My Documents\Python25\lib
C:\Documents and Settings\User\My Documents\Python25\lib\plat-win
C:\Documents and Settings\User\My Documents\Python25\lib\lib-tk
C:\Documents and Settings\User\My Documents\Python25
C:\Documents and Settings\User\My Documents\Python25\lib\site-packages
C:\Documents and Settings\User\My Documents\Python25\lib\site-packages\PIL
C:\Documents and Settings\User\My
Documents\Python25\lib\site-packages\win32
C:\Documents and Settings\User\My
Documents\Python25\lib\site-packages\win32\lib
C:\Documents and Settings\User\My
Documents\Python25\lib\site-packages\Pythonwin
C:\Documents and Settings\User\My
Documents\Python25\lib\site-packages\wx-2.8-msw-ansi

...it just looked horrible to me at first sight!

It looks horrible to me, too. That's why I install applications like that
in "\Apps" instead of a document off of Documents and setings. This looks
much better:

C:\Documents and Settings\User\My Documents\My Python files
C:\Apps\Python25\Lib\idlelib
C:\Apps\Python25\python25.zip
C:\Apps\Python25\DLLs
C:\Apps\Python25\lib
C:\Apps\Python25\lib\plat-win
C:\Apps\Python25\lib\lib-tk
C:\Apps\Python25
C:\Apps\Python25\lib\site-packages
C:\Apps\Python25\lib\site-packages\PIL
C:\Apps\Python25\lib\site-packages\win32
C:\Apps\Python25\lib\site-packages\win32\lib
C:\Apps\Python25\lib\site-packages\Pythonwin
C:\Apps\Python25\lib\site-packages\wx-2.8-msw-ansi

Searching these doesn't really take very long. Remember that it doesn't
have to read all the files -- it only has to read the directories.
>>'C:\Documents and Settings\User\My Documents\My Python files',
'C:\Documents
and Settings\User\My Documents\My Python files\wxDemos'. Now \wxDemos\ is
being searched very early.

... no way! After running AnalogClock.py again, this error message
appears:

------------------------------------------
Traceback (most recent call last):
File "C:\Documents and Settings\My Documents\My Python
files\wxAnalogClock.py", line 14, in <module>
import wx
ImportError: No module named wx.
------------------------------------------

Very strange! Because all this wx stuff IS IN the directory 'C:\Documents
and Settings\User\My Documents\My Python files\wxDemos'. And
AnalogClock.py
does work when residing in that directory.

wxDemos contains the demos. The "wx" module lives in
site-packages\wx-2.8-msw-ansi. Did you leave that in?
--
Tim Roberts, ti**@probo.com
Providenza & Boekelheide, Inc.

Jan 13 '07 #7
I included the "...\wxDemos" path in PYTHONPATH. Everthing fine now!

"siggi" <sm***********@yahoo.comschrieb im Newsbeitrag
news:eo***********@zam602.zam.kfa-juelich.de...
"Tim Roberts" wrote:
>>>
when I do >>>sys.path in IDLE (winXP), i get a horrendously long list of
paths, paths I may have used during a lot of trials and errors. How can I
clean up sys.path? I mean, trim it of unnecessary paths?

What do mean by "used during a lot of trials and errors"? sys.path is
recreated from scratch every time Python starts. It doesn't accumulate
over time, other than from new packages that you install.
--
Tim Roberts, ti**@probo.com
Providenza & Boekelheide, Inc.


Sorry Tim, my statement was not correct, due to my inexperience with
Python.
And sorry, too, for my somewhat lengthy reply:
After having had inspected my current sys.path...

['C:\\Documents and Settings\\User\\My Documents\\My Python files',
'C:\\Documents and Settings\\User\\My Documents\\Python25\\Lib\\idlelib',
'C:\\Documents and Settings\\User\\My Documents\\Python25\\python25.zip',
'C:\\Documents and Settings\\User\\My Documents\\Python25\\DLLs',
'C:\\Documents and Settings\\User\\My Documents\\Python25\\lib',
'C:\\Documents and Settings\\User\\My Documents\\Python25\\lib\\plat-win',
'C:\\Documents and Settings\\User\\My Documents\\Python25\\lib\\lib-tk',
'C:\\Documents and Settings\\User\\My Documents\\Python25', 'C:\\Documents
and Settings\\User\\My Documents\\Python25\\lib\\site-packages',
'C:\\Documents and Settings\\User\\My
Documents\\Python25\\lib\\site-packages\\PIL', 'C:\\Documents and
Settings\\User\\My Documents\\Python25\\lib\\site-packages\\win32',
'C:\\Documents and Settings\\User\\My
Documents\\Python25\\lib\\site-packages\\win32\\lib', 'C:\\Documents and
Settings\\User\\My Documents\\Python25\\lib\\site-packages\\Pythonwin',
'C:\\Documents and Settings\\User\\My
Documents\\Python25\\lib\\site-packages\\wx-2.8-msw-ansi']

or in plain DOS:

C:\Documents and Settings\User\My Documents\My Python files
C:\Documents and Settings\User\My Documents\Python25\Lib\idlelib
C:\Documents and Settings\User\My Documents\Python25\python25.zip
C:\Documents and Settings\User\My Documents\Python25\DLLs
C:\Documents and Settings\User\My Documents\Python25\lib
C:\Documents and Settings\User\My Documents\Python25\lib\plat-win
C:\Documents and Settings\User\My Documents\Python25\lib\lib-tk
C:\Documents and Settings\User\My Documents\Python25
C:\Documents and Settings\User\My Documents\Python25\lib\site-packages
C:\Documents and Settings\User\My Documents\Python25\lib\site-packages\PIL
C:\Documents and Settings\User\My
Documents\Python25\lib\site-packages\win32
C:\Documents and Settings\User\My
Documents\Python25\lib\site-packages\win32\lib
C:\Documents and Settings\User\My
Documents\Python25\lib\site-packages\Pythonwin
C:\Documents and Settings\User\My
Documents\Python25\lib\site-packages\wx-2.8-msw-ansi

...it just looked horrible to me at first sight!

If I interpret your explanation correctly, all these paths are necessary,
and not relics of previous installations and deinstallations.

What puzzles me, though, is, that e.g., when I run the wxPython
application
"AnalogClock.py" with IDLE or in the command line , this works only in the
directory "...\My Python files\wxDemos\" . This directory contains all
files
and folders from the original "\wx-2.8-msw-ansi\demos\").

When I copy AnalogClock.py to ...\My Python Files\ , nothing happens
after
running it with IDLE or in the command line.
Appending 'C:\Documents and Settings\User\My Documents\My Python
files\wxDemos ' to the sys.path does not help either.

Thinking that I am clever, I changed my sys.path with sclicing and
concatenation such that my sys.path starts with

'C:\Documents and Settings\User\My Documents\My Python files',
'C:\Documents
and Settings\User\My Documents\My Python files\wxDemos'. Now \wxDemos\ is
being searched very early.

... no way! After running AnalogClock.py again, this error message
appears:

------------------------------------------
Traceback (most recent call last):
File "C:\Documents and Settings\My Documents\My Python
files\wxAnalogClock.py", line 14, in <module>
import wx
ImportError: No module named wx.
------------------------------------------

Very strange! Because all this wx stuff IS IN the directory 'C:\Documents
and Settings\User\My Documents\My Python files\wxDemos'. And
AnalogClock.py
does work when residing in that directory.

Can you help me again?

Thanks,

siggi

P.S. On another PC where the python program is in c:\programs\python25\,
same as above!


Jan 15 '07 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: somaboy mx | last post by:
I'm looking for a way to come up with clean urls like http://www.mysite.com/products/233 instead of http://www.mysite.com/products.php?pid=233 without having to rely on mod_rewrite or other...
7
by: cpnet | last post by:
I've figured out how to use the <customErrors/> element in my web config file to to redirect 404 errors to a custom error handler. But, it displays an 'ugly' URL in the client's browser. For...
0
by: Stefan Krah | last post by:
Hello, I'm trying to run a Python script as a Windows service with a defined shutdown. The script (enigma-client.py) handles the communications with the server in a distributed computing effort...
2
by: Ronald | last post by:
I just started with dotnetnuke, and with a wrong login (wrong password on a clean install i can crash the application pool from IIS. (when i login with the right username/password information the...
232
by: robert maas, see http://tinyurl.com/uh3t | last post by:
I'm working on examples of programming in several languages, all (except PHP) running under CGI so that I can show both the source files and the actually running of the examples online. The first...
7
by: Ben | last post by:
Hi We are looking for a component that offers that offers the below for Tiff files: Image clean-up (deskew, despeckle) Printing capabilities from VB The ability to add text to image, e.g....
3
by: D.Hering | last post by:
General: How do I download a page's data from a clean url. Specific: I'm using PyQt's QHttp and QUrl classes for requests and acquiring the response, but I can't figure out how to access a...
0
by: Christopher | last post by:
How can I make a vc++ project erase its $(OutDir) upon using the clean command? I tryed Properties->Configuration Properties->General->Extensions to Delete on Clean Add $(ObjDir) And it...
10
by: Simon | last post by:
As title. How to clean out VSWebCache? Any good way to do that? Thanks.
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
4
NeoPa
by: NeoPa | last post by:
Hello everyone. I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report). I know it can be done by selecting :...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
0
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
0
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
2
by: GKJR | last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...

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.