0

I listed my site-packages path following code from another question:

import site
site.getsitepackages()

which returned this result:

['C:\\Users\\bbrown\\AppData\\Local\\Enthought\\Canopy\\User',
'C:\\Users\\bbrown\\AppData\\Local\\Enthought\\Canopy\\User\\lib\\site-packages',
 'C:\\Users\\bbrown\\AppData\\Local\\Enthought\\Canopy\\App\\appdata',
 'C:\\Users\\bbrown\\AppData\\Local\\Enthought\\Canopy\\App\\appdata\\lib\\site-packages',
 'C:\\Users\\bbrown\\AppData\\Local\\Enthought\\Canopy\\App\\appdata\\canopy-1.5.5.3123.win-x86_64',
 'C:\\Users\\bbrown\\AppData\\Local\\Enthought\\Canopy\\App\\appdata\\canopy-1.5.5.3123.win-x86_64\\lib\\site-packages']

Yet (after showing hidden files and folders in my Windows 7 Appearance control panel) it appears that my site packages are exclusively in

C:\Users\bbrown\AppData\Local\Enthought\Canopy\App\appdata\Lib\site-packages

lib vs. Lib. What gives?

Community
  • 1
  • 1
Bennett Brown
  • 5,234
  • 1
  • 27
  • 35

1 Answers1

3

That's just how file paths work on Windows. Windows paths are case-insensitive.

user2357112
  • 260,549
  • 28
  • 431
  • 505
  • 1
    That makes no sense. Why wouldn't the rest of the path be lowercase? – Tom Zych Nov 11 '15 at 18:09
  • 1
    @TomZych: No clue. I'm just saying why the case mismatch isn't causing problems, not why the case mismatch exists. – user2357112 Nov 11 '15 at 18:11
  • The reason why is a combination of how Windows and Python deal with path strings, very historically contingent. But the key takeaway is that you can never make any assumptions about the case of a path in Windows. If you want to compare two paths, you must always case-normalize them first. – Jonathan March Nov 11 '15 at 18:37
  • 1
    Doh. I'm so embarassed that I hadn't realized Windows path were case insensitive that I want to delete my question. But won't. Still begs question: How did Python end up capitalizing the directory in its representation? – Bennett Brown Nov 11 '15 at 19:17
  • 4
    The reason is easy to find in the corresponding code: https://hg.python.org/cpython/file/ee879c0ffa11/Lib/site.py#l297: The `lib\site-packages` part is hardcoded - while the remaining part of the paths is taken from the installation/environment. – sebastian Nov 11 '15 at 19:28
  • @sebastian Good find, you should add that as an answer to the question! user2357112 appears to be answering a different question ("Are windows paths case-sensitive?") – wim Nov 11 '15 at 20:08
  • @wim: Well, it *used* to be a question about case-sensitivity. – user2357112 Nov 11 '15 at 20:10