[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.python

Re: How to add a library path to pythonpath ?

Christian Heimes

3/16/2010 3:56:00 PM

Steve Holden schrieb:
> Barak, Ron wrote:
>> Hi,
>>
>> I'm trying to add a library path to my pythonpath, but seems it is not
>> accepted -
>>
>> On Windows DOS window:
>>
>> C:\>echo %PYTHONPATH%
>> c:\views\cc_view\TS_svm_ts_tool\SVMInspector\lib\
>>
> That looks like it should work. The only thing I notice is that I don't
> have a trailing backslash on my Windows PYTHONPATH. Could that be the
> problem?

Yes, that's definitely a major issue on Windows. Windows' stat() method
returns an error for paths with a trailing (back)slash. For example
_stat("C:\\Windows") works but _stat("C:\\Windows\\") sets errno to
ENOENT or ENOTDIR. I got bitten by the issue a couple of years ago as I
worked on pars of Python's import system.

Quoting Tim Peters: [1]

The Microsoft stat() function is extremely picky about
trailing (back)slashes. For example, if you have a
directory c:/python, and pass "c:/python/" to the MS stat
(), it claims no such thing exists. This isn't documented
by MS, but that's how it works: a trailing (back)slash is
required if and only if the path passed in "is a root". So
MS stat() doesn't understand "/python/", and doesn't
understand "d:" either. The former doesn't tolerate a
(back)slash, while the latter requires one.


Christian

[1] http://mail.python.org/pipermail/python-bugs-list/2002-April/0...