473,218 Members | 1,822 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

how do i add a new path into sys.path?

wen
on my system(win2k server, python 2.3.5),
import sys
print sys.path

['C:\\', 'C:\\WINNT\\system32\\python23.zip',
'C:\\Python23\\lib\\site-packages\\Pythonwin',
'C:\\Python23\\lib\\site-packages\\win32',
'C:\\Python23\\lib\\site-packages\\win32\\lib',
'C:\\Python23\\lib\\site-packages', 'C:\\Python23\\DLLs',
'C:\\Python23\\lib', 'C:\\Python23\\lib\\plat-win',
'C:\\Python23\\lib\\lib-tk', 'C:\\Python23', 'D:\\Program Files\\DeLano
Scientific\\PyMOL\\modules']

now, i wanna add "C:\Python23\Pmw\Pmw_1_2\lib" into sys.path, how?

any help would be appreciated.

with my kind regards,
Wen
Aug 18 '05 #1
10 12785
apa
You can do it this way:

sys.path.append("C:\Temp")

Alejandro

Aug 18 '05 #2
wen wrote:
on my system(win2k server, python 2.3.5),
import sys
print sys.path

['C:\\', 'C:\\WINNT\\system32\\python23.zip',
'C:\\Python23\\lib\\site-packages\\Pythonwin',
'C:\\Python23\\lib\\site-packages\\win32',
'C:\\Python23\\lib\\site-packages\\win32\\lib',
'C:\\Python23\\lib\\site-packages', 'C:\\Python23\\DLLs',
'C:\\Python23\\lib', 'C:\\Python23\\lib\\plat-win',
'C:\\Python23\\lib\\lib-tk', 'C:\\Python23', 'D:\\Program Files\\DeLano
Scientific\\PyMOL\\modules']

now, i wanna add "C:\Python23\Pmw\Pmw_1_2\lib" into sys.path, how?

any help would be appreciated.


hint 1: Python lists have an append() and an insert() method
hint 2: sys.path is a list

HTH
--
bruno desthuilliers
python -c "print '@'.join(['.'.join([w[::-1] for w in p.split('.')]) for
p in 'o****@xiludom.gro'.split('@')])"
Aug 18 '05 #3
wen
if i wanna add the path "C:\temp" into sys.path, and make it available for
any other new python apps, like i add C:\temp into windows path , how?
thank you.

"apa" <ap******@gmail.com> wrote in message
news:11**********************@o13g2000cwo.googlegr oups.com...
You can do it this way:

sys.path.append("C:\Temp")

Alejandro

Aug 18 '05 #4

wen wrote:
if i wanna add the path "C:\temp" into sys.path, and make it available for
any other new python apps, like i add C:\temp into windows path , how?
thank you.


Then use PYTHONPATH as you would use PATH .....

Aug 18 '05 #5
wen
if i wanna add the path "C:\temp" into sys.path, and make it available for
any other new python apps, like i add C:\temp into windows path , how?
thank you.

"apa" <ap******@gmail.com> wrote in message
news:11**********************@o13g2000cwo.googlegr oups.com...
You can do it this way:

sys.path.append("C:\Temp")

Alejandro

Aug 18 '05 #6
apa wrote:
You can do it this way:

sys.path.append("C:\Temp")

Alejandro

Better:

sys.path.append("C:\\Temp")

or

sys.path.append(r"C:\Temp")

regards
Steve
--
Steve Holden +44 150 684 7255 +1 800 494 3119
Holden Web LLC http://www.holdenweb.com/

Aug 18 '05 #7
wen wrote:
on my system(win2k server, python 2.3.5),
import sys
print sys.path


['C:\\', 'C:\\WINNT\\system32\\python23.zip',
'C:\\Python23\\lib\\site-packages\\Pythonwin',
'C:\\Python23\\lib\\site-packages\\win32',
'C:\\Python23\\lib\\site-packages\\win32\\lib',
'C:\\Python23\\lib\\site-packages', 'C:\\Python23\\DLLs',
'C:\\Python23\\lib', 'C:\\Python23\\lib\\plat-win',
'C:\\Python23\\lib\\lib-tk', 'C:\\Python23', 'D:\\Program Files\\DeLano
Scientific\\PyMOL\\modules']

now, i wanna add "C:\Python23\Pmw\Pmw_1_2\lib" into sys.path, how?

any help would be appreciated.

with my kind regards,
Wen


cat clpyaibot.log
* sys.path is instance of <list>.
* "C:\Python23\Pmw\Pmw_1_2\lib" is a [non-raw, living dangerously] string.
* does not compute, trying again under various failure modes ...
* detected Shift key failure
* interpreting "wanna" as "want to"
* parsed chunk: """I want to add <str> into <list>"""
* no such keyword: "add"
* <str>.add ... not found
* <list>.into ... not found
* <list>.addinto ... not found
* checking plausible alternatives ...
* <list>.append(<object>)
* <list>.insert(<index>, <object>)
Aug 18 '05 #8
Steve Holden wrote:
sys.path.append(r"C:\Temp")


In this case, do I need to save the refined path, i.e, the original
paths + the new path (r"C:\Temp"), by using some command in order to use
it permanently. if yes, it would be greatly appreciated to noitce the
correspoding command and the usage of it.

-James
Aug 19 '05 #9
James Sungjin Kim wrote:
Steve Holden wrote:
sys.path.append(r"C:\Temp")

In this case, do I need to save the refined path, i.e, the original
paths + the new path (r"C:\Temp"), by using some command in order to use
it permanently. if yes, it would be greatly appreciated to noitce the
correspoding command and the usage of it.

-James


The method I outlined works only for the duration of a single program
run, because the sys.path variable is set up each time you run the
Python interpreter. You need to look at the suggestions you've had for
setting the PYTHONPATH environment variable to effect changes to all
future Python execution.

Essentially this is most usually done in the "My Computer -> Properties"
dialog: click the "environment variables" button and create a new
(all-users or private, depending on your needs) environment variable
called PYTHONPATH containing a semicolon-separated list of directories
the interpreter should add to the path.

regards
Steve
--
Steve Holden +44 150 684 7255 +1 800 494 3119
Holden Web LLC http://www.holdenweb.com/

Aug 19 '05 #10
Steve Holden wrote:
The method I outlined works only for the duration of a single program
run, because the sys.path variable is set up each time you run the
Python interpreter. You need to look at the suggestions you've had for
setting the PYTHONPATH environment variable to effect changes to all
future Python execution.


Or, often better and cleaner, use .pth files as described in the
documentation for the standard library "site" module.

-Peter
Aug 19 '05 #11

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

Similar topics

8
by: Egor Bolonev | last post by:
hi all i want my program to ignore ntfs links, but os.path.islink() isnt work as i expect print os.path.islink('''C:\Documents and Settings\\My Documents\Scripts\Antiloop\'''') outputs...
2
by: Steven Burn | last post by:
Oks, I know I'm going to seem completely stupid here but, I have a question thats been doing my head in for the last few hours. Basically, I'm trying to find a way to turn a folder and file path,...
2
by: \A_Michigan_User\ | last post by:
Ok, I give up. I need to #include the same 1 file (IncludeThis.asp) into 3 different asp files. 1> C:\MyDir\ThisFile.asp 2> D:\MyDir\AASubSub\ThatFile.asp 3>...
34
by: Reinhold Birkenfeld | last post by:
Hi, the arguments in the previous thread were convincing enough, so I made the Path class inherit from str/unicode again. It still can be found in CVS:...
1
by: Matt | last post by:
In test() method: var path="C:\test\hello.txt"; //returns -1 for path.lastIndexOf("\\"). why?? var pos=path.lastIndexOf("\\"); //return -1 But in showFile() method: We are able to get the...
1
by: William Stacey [MVP] | last post by:
I need a bullet proof way to combine a root and a relative path to form a FQ rooted path (similar to a VDir in IIS). Path.Combine alone will not do the job in all cases. I also need to be sure...
4
by: python | last post by:
Bad file names, i.e. filenames the OS considers illegal, will cause functions in the os.path module to raise an error. Example: import os.path print os.path.getsize( 'c:/pytest/*.py' ) On...
34
by: Alexnb | last post by:
Gerhard Häring wrote: No, it didn't work, but it gave me some interesting feedback when I ran it in the shell. Heres what it told me: Traceback (most recent call last): File...
8
by: moondaddy | last post by:
I'm posting code for a user control ( FunctionConnectorSelector) below which has 3 content controls in it. each content control uses a style from a resource dictionary merged into the app.xaml...
6
by: bukzor | last post by:
I have to go into these convulsions to get the directory that the script is in whenever I need to use relative paths. I was wondering if you guys have a better way: from os.path import dirname,...
1
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...
0
by: veera ravala | last post by:
ServiceNow is a powerful cloud-based platform that offers a wide range of services to help organizations manage their workflows, operations, and IT services more efficiently. At its core, ServiceNow...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
0
by: jianzs | last post by:
Introduction Cloud-native applications are conventionally identified as those designed and nurtured on cloud infrastructure. Such applications, rooted in cloud technologies, skillfully benefit from...
0
by: mar23 | last post by:
Here's the situation. I have a form called frmDiceInventory with subform called subfrmDice. The subform's control source is linked to a query called qryDiceInventory. I've been trying to pick up the...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...

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.