This project has moved and is read-only. For the latest updates, please go here.

Intellisense recognizes 'pil' but not 'PIL' for Pillow fork of Python Imaging Library.

Nov 10, 2014 at 3:18 AM
Not a deal breaker, but Intellisense seems to only recognize the Python Image Library module if it's imported as 'pil' instead of the uppercase 'PIL'. However, different Python environments can be picky as to which capitalization is chosen. Honestly it was a fight to get it to recognize either, eventually it recognized the lower case spelling, although I had the directory named in upper case when it finally added the module to the database.
The fully capitalized spelling is always safe it seems while if I use the lowercase, some code runs everywhere, some doesn't (this does not seem to vary depending on if the directory the module is installed in uses either the all caps or all lower case spelling). Beats me why, but, there it is.
I'd love to have 'PIL' be an alias for 'pil' as far as intellisense is concerned so I don't have to worry about revising all existing projects to lowercase and back all the time if that can be done. Equally, if anyone knows how to stop this oddness in the first place so that a solution is moot, that works too.
Nov 10, 2014 at 6:29 AM
Python package/module names are meant to be case-sensitive - you can get away with mixing case on Windows due to case-insensitive nature of the filesystem, but it won't be portable to Unix. For PIL, as it comes from the author, the proper name for the package is "PIL", as seen in the documentation. If you want to have it lowercased, just alias the module when importing it, e.g.:
import PIL as pil
Or if you want to have both:
import PIL
pil = PIL
With respect to Intellisense recognizing the spelling when you rename the package directory, keep in mind that it has to re-analyze the package when you do that, and while it will happen automatically as it detects changes on disk, it is an asynchronous process that is not instant - i.e. if you renamed it to lowercase, then switched to VS and tried it, then renamed it back to uppercase, then switched to VS again, you might have been seeing completions from the previous refresh (which cached the lowercased name), and a new refresh was still in progress.
Nov 10, 2014 at 4:01 PM
Actually, I don't think our current system will detect case-only changes in names. This is probably fixable, though we rely so heavily on the file system for accurate information that there are likely to be so many edge cases that it's hardly worth it.

If you change the casing of a library in site-packages, you'll need to delete the matching files from your completion DB (located under %LocalAppData%\Python Tools\CompletionDB\<VS version>\<interpreter GUID>\<interpreter version>. However, for compatibility between Python on Windows and on Linux, you should really leave the names with the same case as when they were installed (MacOS is a bit strange as it is optionally case-sensitive, but the same suggestion applies anyway).
Nov 17, 2014 at 10:10 PM
Sorry for the long delay in response and thanks.
I had not changed the capitalization, it was always 'PIL', so I was completely confused as to why it would recognize lower case at all.
A brief aside, for a few updates to the PIL fork I use (pillow) the capitalization would switch from one casing to another, but has been steady with the capitalization since I built the computer I'm working on now. It's out of habit that I went to look to see if they had gone to lower case again on the last update, as I used to regularly have to change the directory back to uppercase.
To pminaev: I had not switched around the capitalization, but decided to follow the gist of your suggestion and just wait for a bit to see if eventually the database updated and sorted itself out. As of about 5 minutes ago, it finally has done so.
So, good advice to just be patient. Also, I'm embarrassed to admit I forgot all about "import . . . as . . .". The second I saw that typed out I recognized. I have seen that aliasing on import reading examples when I was having trouble learning something, but it was not a habit I ever picked up. Since I'm just a hobbyist, I sometimes have to wait weeks to have time to pick a project up again, and learned that clarity helps me pick up where I left off quickest, so, I just leave module names in full and forgot that was even an option I guess.
Thank you for the information and yes, seems I just had to wait. Really only a few hours since I was working in Wing over the past week or so, and as a result VS was only running an hour or two over that time, but, it's fine now
To Zooba: As I said, I hadn't changed the casing, but it did work itself out. Not sure what happened but if you want me to send any logs or the like I'm happy to do so. I do try to keep the casing the same since who knows what I'll be working with in the future, so, just have good practices now and I won't have a headache later.

Thank you both again, and, if I can supply any info to help clarify how it resolved, let me know. Otherwise, just needed patience.