0

Short question :

enter image description here

Why??

I did install pywin32.And I can peek definition of other packages just fine. And my program works just fine. I just can't work out why I can't peek the definition of it?

And moreover, how does python found some package was actually installed ? By looking for the subfolder inside site-packages ?

ratsafalig
  • 442
  • 5
  • 21
  • -The "Go to Definition" in VS Code indeed searches for the source file from "lib\site-packages" of the currently selected Python environment. Does the VS Code terminal display its installation information when you type "pip show win32ui"? – Jill Cheng Feb 05 '21 at 06:00
  • `pip show win32ui` output nothing. but `pip show pywin32` works fine – ratsafalig Feb 05 '21 at 06:48
  • -"pywin32" is stored as a module in "lib\site-packages", but there is no "win32" here, so the "Go to Definition" function cannot find it. – Jill Cheng Feb 05 '21 at 06:51
  • But strangely I can `import win32gui` and it works fine... I think this is something to do with that the `win32gui` module is a `.pyd` file( DLL file) , which doesn't contain any python stuff ? – ratsafalig Feb 05 '21 at 06:55
  • -I noticed that there are some "win32ui" files in the Python source files (for example: "\Users\username\AppData\Roaming\Python\Python38\site-packages\~ythonwin" has a "win32ui.pyd"), but VS Code cannot recognize this file. – Jill Cheng Feb 05 '21 at 07:24

1 Answers1

1

Might be helpful to check if you are running the right version of python with vscode.

In short- you might have different versions of python installed on your pc, installed by you or some other work environments(vscode might have installed one for you). You can see the current running version on the bottom left the bottom left of your vscode window(given that you are running the ms-python.python extesnion).

If it is not the appropriate version, you can easily change it by pressing on the text of the version, see below picture:

enter image description here

barshopen
  • 1,190
  • 2
  • 15
  • 28
  • I did run on the correct version. and by the way, any other package works just fine.but just this `pywin32` – ratsafalig Feb 04 '21 at 13:26
  • This "by the way" is a crucial piece of information here :). You should have started with that. Did you ever manage to use the `import win32ui` command in vscode and get good results? Did you try to import it in python shell to see if you successfully import the package? – barshopen Feb 04 '21 at 13:33
  • 1
    thank you for your remind, I'll add to the question. And yes, it successfully imported – ratsafalig Feb 04 '21 at 13:40
  • I think problem with this `pywin32` is that it is a library that works with some system-level-things. So maybe there doesn't really exist a python file to this library? – ratsafalig Feb 04 '21 at 13:46
  • Maybe this thread can help? https://stackoverflow.com/questions/44063350/python-no-module-named-win32gui-after-installing-pywin32?rq=1 – barshopen Feb 04 '21 at 16:46
  • To be honest, not really. But this bring me a new througnt : how vscode can peek a definition if the package is a DLL ? Cause the `win32gui` module itself is a `.pyd` file, which is basically a `DLL` – ratsafalig Feb 05 '21 at 06:53