Wednesday, June 1, 2022

[SOLVED] Pip install does not work, matplotlib seems to be broken, pyenv and fresh new install doesn't work

Issue

So I wanted to import matplotlib to my virtual python version of 3.10.0 (and other versions). I install it as usual:

pip install matplotlib

Everything seems to work, no errors show up with pip. But when I try to run this code snippet in vs code (to see if mpl works):

import matplotlib

print(matplotlib.__version__)

It outputs this:

File "/Users/XYZ/Desktop//pienv.py", line 1, in <module>
    import matplotlib
  File "/Users/XYZ/Desktop//matplotlib.py", line 1, in <module>
    import matplotlib.pyplot as plt
ModuleNotFoundError: No module named 'matplotlib.pyplot'; 'matplotlib' is not a package

But when I do the same in the terminal it outputs the correct version. It doesn't matter if I have python installed with dmg file or with pyenv, result is the same.

I tried to format operating system to ensure there is no os trash that might be getting in a way. Then I just installed python with pyenv.

I'm using osx 12.0.1

My vscode setup is straightforward, just python extension and python interpreter set to what pyenv has as a local python.

Is there that can be done, or that I'm doing wrong?


Solution

Found the answer.

It's just a stupid thing.

Don't name your projects with the names of your libraries when they're in the same directory.



Answered By - Bartey
Answer Checked By - Timothy Miller (WPSolving Admin)