Newbie question about module paths

Nov 27, 2014 at 4:18 PM
Edited Nov 28, 2014 at 9:45 AM
Hi

I am running PTVS 2.1 and it works nicely.

Today I installed a module called path.py:

easy_install path.py

It's installed in:

c:\Python27\lib\site-packages\path.py-7.0-py2.7.egg\path.pyc

How can I tell PTVS to use that path for intellisense? (Code completion is not working on the path class).

I tried refreshing the database, but that didn't help.

BR

David
Dec 2, 2014 at 10:20 AM
Hi

I tried adding this search path to my project:

c:\Python27\lib\site-packages

But Intellisense for path.py is still not working.

Any suggestions please?

BR

David
Coordinator
Dec 2, 2014 at 7:04 PM
You won't need to add that as a search path, and it's likely to cause more problems if you do.

Do you have a path.py file installed alongside the .pyc file? If not, then that's why there's no IntelliSense - we can't figure anything useful out from a .pyc.

You may need to try installing it with pip instead of easy_install, or looking at some of the options for easy install (easy_install -h, if I recall correctly) and getting it to install the source and not just the precompiled version.
Dec 4, 2014 at 3:44 PM
I tried installing path.py with pip:

C:>pip install path.py
Requirement already satisfied (use --upgrade to upgrade): path.py in c:\python27
\lib\site-packages\path.py-7.0-py2.7.egg
Cleaning up...

Do you know how I can get pip to install the source code?

David
Dec 4, 2014 at 4:13 PM
Using pip, I unsintalled path.py and then installed it. Now I see:

Directory of C:\Python27\Lib\site-packages

04/12/2014 16:07 <DIR> .
04/12/2014 16:07 <DIR> ..
04/12/2014 16:06 215 easy-install.pth
04/12/2014 16:07 48,720 path.py
04/12/2014 16:07 <DIR> path.py-7.0-py2.7.egg-info
04/12/2014 16:07 53,990 path.pyc
04/12/2014 15:37 <DIR> pip
04/12/2014 15:37 <DIR> pip-1.5.6.dist-info
28/10/2005 19:07 121 README.txt
27/11/2014 09:03 753,586 setuptools-7.0-py2.7.egg
27/11/2014 09:03 28 setuptools.pth
04/12/2014 16:07 31,556 test_path.py
04/12/2014 16:07 32,638 test_path.pyc

But PTVS is still not offering code completion on path. I refreshed the database but that didn't help.
Coordinator
Dec 4, 2014 at 5:50 PM
Very strange. There doesn't seem to be anything wrong with the library itself.

In VS, if you go to Tools->Python Tools you'll see an item called Diagnostic Info. Can you share that info with us (either put it online somewhere or email an attachment to ptvshelp@microsoft.com)? It includes some of our logs that may reveal what's going wrong.
Dec 5, 2014 at 10:24 AM
In VS, if you go to Tools->Python Tools you'll see an item called Diagnostic Info. Can you share that info with us (either put it online somewhere or email an attachment to ptvshelp@microsoft.com)? It includes some of our logs that may reveal what's going wrong.
Thanks, I have emailed it to you.
Coordinator
Dec 15, 2014 at 11:46 PM
(Apologies for the delay - your email ended up in my spam folder)

According to the logs, it's been analysed correctly, so we're probably looking at a different problem.

If you type "import pa", do you see "path" appear in that list? What about "test_path"? According to the logs, you should see both of those.
Dec 16, 2014 at 9:28 AM
Zooba wrote:
If you type "import pa", do you see "path" appear in that list? What about "test_path"? According to the logs, you should see both of those.
Yes, I see both of those. But I still don't get completion in my code. Here is a code snippet:
from path import path
import sys

def getDirStats(myPath):
  d=path(myPath)
Typing d. gives no completions.

David
Coordinator
Dec 16, 2014 at 5:23 PM
Ah, I see. path.py uses a trick to create an alias path.path for the class path.Path, and we aren't able to recognize this in our code analyser. If you write from path import Path as path then you'll get identical behaviour and you should get better completions.

(For what it's worth, if the author of path.py had simply written path = Path in their module, it would have worked exactly the same and we would have been able to understand it. There's no need for the trick that was used.)
Marked as answer by DavidA2014 on 12/17/2014 at 5:36 AM
Dec 17, 2014 at 1:36 PM
If you write from path import Path as path then you'll get identical behaviour and you should get better completions.
That worked perfectly. Code completion is now working.

Thanks very much for your help and patience.

Best regards

David