-
Notifications
You must be signed in to change notification settings - Fork 764
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cell magics break Pylance in Jupyter notebooks #6889
Comments
Can you include the logs as described here: They should list out why we can't find an import. It should be looking in the same import path as the kernel selected in the notebook. |
I started logging, and when I run my notebook, the output panel is blank. I'm getting all these "not defined" errors on imports. |
That would mean you don't have Pylance installed or it failed to start for some reason. Is pylance listed in the extensions tab? If it is, can you look in the Help | Developer Tools -> Console and see if there are any errors there? |
Additionally, the Python output tab may show some errors for whether or not Pylance started. The Python extension starts the pylance extension. |
Okay, now I have the log output. I can only share a short excerpt here:
|
You cut it off right in the part where it's saying why it can't find mlx_lm. That is listing the paths where it looked for it.
The first line though is where I'd expect it to be:
Is that where you installed it? |
It should be there. The notebook runs and can import the library, but Pylance apparently can't find it. I'm using a virtual environment inside this directory. |
Pylance would be looking for the directory 'mlx_lm' in the site-packages folder. Does it exist? Perhaps 'mlx_lm' is a strange install. |
It exists. Everything that should be installed runs fine in the notebook, but with no intellisense because Pylance can't find anything. |
Can you include the full log? It should list out what exactly it was looking for. I'm having trouble myself installing 'mlx-lm'. |
I don't see the 'mlx-lm' import listed there but a bunch of others. They're all looking here:
If you run this code in a cell, what does it say: import tensorflow
tensorflow.__file__ |
Tensorflow is not imported by the code running in the notebook. I think that's an artifact of Transformers. It's not installed and not needed. Perhaps mlx_lm is a better example: |
So this log is from something that imports 'mlx_lm' and gives the error you mentioned? I don't see that in the log. It should show an import error if it's giving the import unresolved error in the IDE. |
I mean maybe the bug here is that the errors aren't being updated and it is finding 'mlx_lm' |
What happens if you run 'Python: Restart Language Server'? |
Yes, this is the log from the notebook that's importing mlx_lm. Restarting the language server doesn't change anything. |
By the way, you can see several other people complaining about this same problem in the ratings of Pylance on the VS Code extension store. |
Is this the notebook? It's this: %%capture
import mlx_lm
from IPython.display import display, clear_output, Markdown
|
Which is an enhancement request: |
Wow, well that's really not obvious. But now I get errors like this in code that works:
|
Also this, even though Markdown works.
|
The Markdown error is the same issue. If you're importing it in a cell with The other problem is likely to do with the typing of the NaiveStreamingDetokenizer. It may be incorrectly typed or we can't infer types for some reason. |
Okay, thanks for walking me through this. Unfortunately I have always had so much trouble getting tooling set up properly for Python. The whole experience is so complicated. There are so many steps you need to go through with VS Code. I don't know how beginners manage it. |
Environment data
Repro Steps
Expected behavior
Intellisense works on mouseover
Actual behavior
All imports have this error on mouseover: "some_import" is not defined. Pylance doesn't work at all.
The text was updated successfully, but these errors were encountered: