0

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?

Andy Lester
  • 91,102
  • 13
  • 100
  • 152
  • I recommend using the [Anaconda Distribution](https://www.anaconda.com/products/individual), it's likely to make your life much easier. All packages are installed as precompiled binaries. [Package List](https://docs.anaconda.com/anaconda/packages/py3.8_win-64/) – Trenton McKinney Nov 22 '21 at 18:38

1 Answers1

0

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.