Skip to content

Language Server: unable to recognize mpl_toolkits from matplotlib #2319

Description

@MarkyMark1000

Environment data

  • VS Code version: 1.25.1
  • Extension version (available under the Extensions sidebar): ?
  • OS and version: MacOS Sierra 10.12.6
  • Python version (& distribution if applicable, e.g. Anaconda): See below.
  • Type of virtual environment used (N/A | venv | virtualenv | conda | ...): N/A
  • Relevant/affected Python packages and their versions:
    conda version 4.5.8
    condo-build-version 3.12.0
    python version: 3.6.6.final.0

Actual behaviour

I am new to vs code and python so please forgive any errors. I have posted a previous issue and somebody asked me to add a new issue here. The previous post was:

microsoft/vscode-docs#1757

I can run the following code on visual studio code and it appears to work, however there are 2 problems:

  1. With the import statement for mpl_toolkits.mplot3d, it is saying:
Unable to resolve 'mpl_toolkits.mplot3d', intellisence may be missing for this module
  1. The piece of code that contains facecolors=cm.inferno(G) is highlighting the cm with a red underscore and saying:
[pylint] E1101: Module 'matplotlib.cm' has no inferno member.

Expected behavior

I believe this is a problem with linting. The code runs and works on both vs code and spyder, but looks horrible because of the red formatting.

Steps to reproduce:

  1. Create a python file and copy it in:
# SurfacePlot3D.py
import matplotlib.pyplot as plt
from matplotlib import cm
from mpl_toolkits.mplot3d import Axes3D
import numpy as np

X, Y = np.meshgrid(np.arange(-100, 100), np.arange(-100,100))
Z = X ** 2 + Y ** 2

G_x, G_y = np.gradient(Z)
G = np.sqrt(G_x2 + G_y2)
G = G / G.max()

#Figure contains all of the objects in the plot
fig = plt.figure()
#Get the axes of the plot
ax = Axes3D(fig)
#THIS DOESN'T WORK IN VS Code, but works in Spyder
#Uncomment the following line to plot the surface.
ax.plot_surface(X,Y,Z, facecolors=cm.inferno(G))
#Show the Plot
plt.show()

Logs

Output for Python in the Output panel (View→Output, change the drop-down the upper-right of the Output panel to Python)

##########Linting Output - pylint##########
************* Module SurfacePlot3D
20,34,error,E1101:Module 'matplotlib.cm' has no 'inferno' member

------------------------------------------------------------------
Your code has been rated at 6.15/10 (previous run: 6.15/10, +0.00)

Output from Console under the Developer Tools panel (toggle Developer Tools on under Help)

TMSyntax.ts:47 Overwriting grammar scope name to file mapping for scope source.python.
Old grammar file: file:///Applications/Development/Visual%20Studio%20Code.app/Contents/Resources/app/extensions/python/syntaxes/MagicPython.tmLanguage.json.
New grammar file: file:///Users/mark/.vscode/extensions/magicstack.magicpython-1.0.12/grammars/MagicPython.tmLanguage

<img width="1440" alt="screen shot 2018-08-02 at 16 02 52" src="https://user-images.githubusercontent.com/41428873/43592523-a53f7c92-966d-11e8-8766-0d784043577b.png">
<img width="1440" alt="screen shot 2018-08-02 at 16 02 25" src="https://user-images.githubusercontent.com/41428873/43592526-a5630374-966d-11e8-8b57-1008ef29c382.png">
<img width="1440" alt="screen shot 2018-08-02 at 16 02 12" src="https://user-images.githubusercontent.com/41428873/43592528-a58d129a-966d-11e8-9bd3-1eda46f5d641.png">
<img width="1440" alt="screen shot 2018-08-02 at 16 09 53" src="https://user-images.githubusercontent.com/41428873/43593008-b52d5614-966e-11e8-9c0e-2d3c536311dd.png">

Activity

  1. added
    bugIssue identified by VS Code Team member as probable bug
    area-intellisenseLSP-related functionality: auto-complete, docstrings, navigation, refactoring, etc.
    on Aug 2, 2018
  2. ericsnowcurrently commented on Aug 2, 2018

    @ericsnowcurrently

    Hi MarkyMark1000. Thanks for reporting this issue. What version of the extension are you using? You can find it under the extensions tab on the left. The latest version of the extension is 2018.7.1.

    Just to make sure I understand, the code is working fine but intellisense and the linter are reporting errors they shouldn't be?

  3. MarkyMark1000 commented on Aug 2, 2018

    @MarkyMark1000
    Author

    Hi ericsnowcurrently,

    I have many extensions enabled, but if you mean the Python one, then, yes it is 2018.7.1

    Sorry, I thought that I included an image of my extensions, but it has not uploaded properly or has been deleted.

    Thanks

    Mark

  4. MarkyMark1000 commented on Aug 2, 2018

    @MarkyMark1000
    Author

    Oh and yes, the code appears to be working fine. Intellisense and linter are reporting errors that they shouldn't be.

    Thanks

    Mark

  5. ericsnowcurrently commented on Aug 2, 2018

    @ericsnowcurrently

    How are you running the code? Note that if you have not selected the interpreter from your conda environment then the linter and intellisense are not going to be able to find packages that you installed in your environment, using the global environment instead.

  6. 13 remaining items

  7. MarkyMark1000 commented on Aug 9, 2018

    @MarkyMark1000
    Author

    I will attempt to show an image of VS Code Insiders (originally I was using VS Code). It no longer has the mplot3d issue, but still displays the following error:

    [pylint] E1101:Module 'matplotlib.cm' has no 'inferno' member.

    Please note that this is being run on a Mac.

    The graph can however still be built when the code is run:

    screen shot 2018-08-09 at 22 38 01

  8. changed the title [-]VS Code, Python, Linting, mpl_toolkits.mplot3d and cm.inferno(G)[/-] [+]Language Server: unable to recognize mpl_toolkits from matplotlib[/+] on Aug 20, 2018
  9. brettcannon commented on Aug 20, 2018

    @brettcannon
    Member

    In the latest version of the language server on Windows 10 that mpl_toolkits is not recognized as a viable module.

    MarkyMark1000 as for the Pylint problem, that's going to be a Pylint problem. 😉 Basically Pylint can't always pick up on all modules because of how they are defined.

  10. MarkyMark1000 commented on Aug 23, 2018

    @MarkyMark1000
    Author

    Hi Brettcannon,

    Please note that I am running this on a mac, not windows.

    As far as I can tell, the code executes correctly on a mac, but the issue with pylint and the following still remains:

    [pylint] E1101:Module 'matplotlib.cm' has no 'inferno' member.

    Am I in the correct area to report problems with pylint ? Should this be added to another blog ?

    Regards

    Mark

  11. brettcannon commented on Aug 23, 2018

    @brettcannon
    Member

    MarkyMark1000 Yep, I realize you're on macOS. My comment was meant to convey that I can reproduce the mpl_toolkits problem but not your other import problem.

    And the Pylint issue can be reported to Pylint if you want, but that we have nothing to do with the cause of the message.

  12. MikhailArkhipov commented on Aug 23, 2018

    @MikhailArkhipov
  13. MikhailArkhipov commented on Aug 23, 2018

    @MikhailArkhipov

    I found the issue, have solution

    image

  14. locked as resolved and limited conversation to collaborators on Oct 3, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

area-intellisenseLSP-related functionality: auto-complete, docstrings, navigation, refactoring, etc.bugIssue identified by VS Code Team member as probable bug

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions