473,807 Members | 2,884 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

problem in appending a path to sys.path

Hi
I am having a problem in appending to sys.path
I am doing it this way:
sys.path ['D:\\PYTHON23', 'D:\\PYTHON23\\ Lib\\idlelib',
'D:\\WINNT\\sys tem32\\python23 .zip',
'D:\\PYTHON23\\ lib\\site-packages\\Pytho nwin',
'D:\\PYTHON23\\ lib\\site-packages\\win32 ',
'D:\\PYTHON23\\ lib\\site-packages\\win32 \\lib',
'D:\\PYTHON23\\ lib\\site-packages', 'D:\\Python23\\ DLLs',
'D:\\Python23\\ lib', 'D:\\Python23\\ lib\\plat-win',
'D:\\Python23\\ lib\\lib-tk', 'D:\\Python23'] sys.path.append (r'D:\Python23\ Lib\site-packages\code')
sys.path ['D:\\PYTHON23', 'D:\\PYTHON23\\ Lib\\idlelib',
'D:\\WINNT\\sys tem32\\python23 .zip',
'D:\\PYTHON23\\ lib\\site-packages\\Pytho nwin',
'D:\\PYTHON23\\ lib\\site-packages\\win32 ',
'D:\\PYTHON23\\ lib\\site-packages\\win32 \\lib',
'D:\\PYTHON23\\ lib\\site-packages', 'D:\\Python23\\ DLLs',
'D:\\Python23\\ lib', 'D:\\Python23\\ lib\\plat-win',
'D:\\Python23\\ lib\\lib-tk', 'D:\\Python23',
'D:\\Python23\\ Lib\\site-packages\\code']

But when I close the shell and now again open it & do sys.path , it
doesnt show the path I last appended. i.e
import sys
sys.path

['D:\\PYTHON23', 'D:\\PYTHON23\\ Lib\\idlelib',
'D:\\WINNT\\sys tem32\\python23 .zip',
'D:\\PYTHON23\\ lib\\site-packages\\Pytho nwin',
'D:\\PYTHON23\\ lib\\site-packages\\win32 ',
'D:\\PYTHON23\\ lib\\site-packages\\win32 \\lib',
'D:\\PYTHON23\\ lib\\site-packages', 'D:\\Python23\\ DLLs',
'D:\\Python23\\ lib', 'D:\\Python23\\ lib\\plat-win',
'D:\\Python23\\ lib\\lib-tk', 'D:\\Python23']

What am I doing wrong here??
Jul 18 '05 #1
3 2272
>>>>sys.path.ap pend(r'D:\Pytho n23\Lib\site-packages\code')
sys.path
['D:\\PYTHON23', 'D:\\PYTHON23\\ Lib\\idlelib',
'D:\\WINNT\\sys tem32\\python23 .zip',
'D:\\PYTHON23\\ lib\\site-packages\\Pytho nwin',
'D:\\PYTHON23\\ lib\\site-packages\\win32 ',
'D:\\PYTHON23\\ lib\\site-packages\\win32 \\lib',
'D:\\PYTHON23\\ lib\\site-packages', 'D:\\Python23\\ DLLs',
'D:\\Python23\\ lib', 'D:\\Python23\\ lib\\plat-win',
'D:\\Python23\\ lib\\lib-tk', 'D:\\Python23',
'D:\\Python23\\ Lib\\site-packages\\code']

But when I close the shell and now again open it & do sys.path , it
doesnt show the path I last appended. i.e

import sys
sys.path


['D:\\PYTHON23', 'D:\\PYTHON23\\ Lib\\idlelib',
'D:\\WINNT\\sys tem32\\python23 .zip',
'D:\\PYTHON23\\ lib\\site-packages\\Pytho nwin',
'D:\\PYTHON23\\ lib\\site-packages\\win32 ',
'D:\\PYTHON23\\ lib\\site-packages\\win32 \\lib',
'D:\\PYTHON23\\ lib\\site-packages', 'D:\\Python23\\ DLLs',
'D:\\Python23\\ lib', 'D:\\Python23\\ lib\\plat-win',
'D:\\Python23\\ lib\\lib-tk', 'D:\\Python23']

What am I doing wrong here??

sys.path changed for the same reason why if you set
a="puke"
in the interpreter and then closed the shell and restarted the
interpreter, the variable a would have no value!!
You are not making a permanent change to sys.path using sys.append!!
I think you really want to modify the PYTHONPATH environment variable,
I'd guess.

Jul 18 '05 #2
ke***********@y ahoo.com wrote:

What am I doing wrong here??


As rabbits77 said, your change is not being persisted. What you
can do instead of using PYTHONPATH, if you wish, is read the header
comment in the file python\lib\site .py (i.e. look in your Python
folder tree for that file) and create a ".pth" file with the appropriate
contents. As you are on Windows, make sure you take care to create it
with a lower-case extension, not .PTH, as site.py is case-sensitive in
this respect.

-Peter
Jul 18 '05 #3
Peter Hansen <pe***@engcorp. com> wrote in message news:<40******* ********@engcor p.com>...
ke***********@y ahoo.com wrote:

What am I doing wrong here??


As rabbits77 said, your change is not being persisted. What you
can do instead of using PYTHONPATH, if you wish, is read the header
comment in the file python\lib\site .py (i.e. look in your Python
folder tree for that file) and create a ".pth" file with the appropriate
contents. As you are on Windows, make sure you take care to create it
with a lower-case extension, not .PTH, as site.py is case-sensitive in
this respect.

-Peter

Thanks
this is exactly what I was looking for
Jul 18 '05 #4

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

Similar topics

6
1416
by: vegetax | last post by:
I am trying to make convert a directory "tree" in a list of list, but cant find the algoritm =( ,for example a directory tree like : +root  +doc    ele1    ele2    +doc3     ele3  +doc2
1
2899
by: Amit Gangrade | last post by:
I am trying to make a configure script for a c++ library . The library can be compiled with some optional header files,depending on the users decision . So basically I need to check for the headers in the path that the user gives in the --with-somelibrary-include="somedirectory" . I am appending the path of "somedirectory" to CPPFLAGS and then using AC_TRY_COMPILE macro , I am trying to compile a program which includes those optional...
8
1446
by: John M. Gabriele | last post by:
I'm putting together a small site using Python and cgi. (I'm pretty new to this, but I've worked a little with JSP/servlets/Java before.) Almost all pages on the site will share some common (and static) html, however, they'll also have dynamic aspects. I'm guessing that the common way to build sites like this is to have every page (which contains active content) be generated by a cgi script, but also have some text files
0
1545
by: Greg McIntyre | last post by:
Out of interest, are there any standard Python modules that do this: def appendRelativeIncludePath(*relpath): dir = os.path.abspath(os.path.join(os.path.dirname(__file__), *relpath)) if not dir in sys.path: sys.path.append(dir) I ask because I often find myself doing this: ----
17
2577
by: djmob | last post by:
I am very new to .NET and Windows programming in general so please bare with me... I created a Windows service by deriving a class from ServiceBase and installing it via the 'sc create' commands as follows: sc create <name> binPath= <path> Where path is the fully qualified path name. The new service appeared in the Services GUI and I was able to start and stop it without problems. Next I
7
12935
by: siggi | last post by:
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,
5
10045
by: =?Utf-8?B?SmVmZiBCZWVt?= | last post by:
Before you respond with "just use GetShortPathName" please read the rest. We have an application that places files on a file server using mapped drives as it's path of choice. The reason for this is because using a UNC paths makes the path longer, causing the periodic problem with a path that is too long (over 260 chars). We also have an asp.net app that needs to access those files. Accessing mapped drives from an IIS application is...
4
1503
by: John [H2O] | last post by:
I have a glob.glob search: searchstring = os.path.join('path'+'EN*') files = glob.glob(searchstring) for f in files: print f ___ This returns some files:
1
2815
by: milica | last post by:
So many web sites state that $ENV{‘PATH’} = “/newpath:$ENV{‘ PATH’}”; should append to path. When I include that in perl code, and echo $PATH afterwards, or just type env, there is no change in $path. ??? Any ideas? Thanks. M.
0
10372
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...
0
10112
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9193
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6879
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
5546
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...
0
5685
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4330
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
3854
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3011
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.