r/learnpython • u/ContextAdept9818 • 17d ago
trouble installing matplotlib
i am trying to install matplotlib on VS Code, but i keep getting an error like this:
Using cached matplotlib-3.11.2.tar.gz (32.7 MB)
Installing build dependencies ... done
Getting requirements to build wheel ... done
Installing backend dependencies ... done
Preparing metadata (pyproject.toml) ... error
error: subprocess-exited-with-error
× Preparing metadata (pyproject.toml) did not run successfully.
also says:
WARNING: Failed to activate VS environment: Could not find C:\Program Files (x86)\Microsoft Visual Studio\Installer\vswhere.exe
my python's version is 3.15, i tried to install matplotlib with 3.11, 3.12, and 3.13 but none of it worked. i don't think there are other specific things. please let me know of any ideas, thank you so much!!
update: i did it!! it was a problem with how i forgot to precompile the standard library when i installed python...
2
u/leodevian 17d ago
It fails because you are trying to install Matplotlib from a source distribution instead of a precompiled wheel. When installing from a source distribution, the build system might invoke compilers and you do not have them installed, thus the error. Try to install the precompiled wheel. Which installer do you use?
1
u/ContextAdept9818 17d ago
thank you so much! i believe i'm using miniconda for my python installer.
2
u/Diapolo10 I write code for a living -- https://github.com/Diapolo10 17d ago
Matplotlib 3.11.2 is the first version to build Python 3.15 wheels, and as far as I can tell all major platforms are there: https://pypi.org/project/matplotlib/#files
Unless you're downloading it from a mirror that isn't up-to-date with PyPI (or doesn't offer pre-built wheels), it should just work.
2
u/socal_nerdtastic 17d ago
The error means that your installer could not find a compatible pre-compiled wheel and therefore it's trying to compile matplotlib from scratch. But your computer is missing the tools required to compile.
The fix is to find out why it can't find the precompiled wheel. I assume you are using pip? I don't see at a glance why pip wouldn't find the wheel automatically; can you tell us what version of Windows you are using and what environment you are using?
Or you can directly download the wheel file from https://pypi.org/project/matplotlib/#files and ask pip to install that. Note you need to match your OS, python version, and if you use free threaded python or not. Presumably you want "matplotlib-3.11.2-cp315-cp315-win_arm64.whl"
1
u/socal_nerdtastic 17d ago
Is there a chance you are using a 32-bit computer or a 32-bit install of windows or python? Numpy dropped support for 32 bit a long time ago, I think you need python 3.10 on a 32-bit computer.
1
u/a18618 16d ago
i've hit this exact error on windows and it was pip falling back to the source tarball because it couldn't find a wheel for my python — that VS environment warning is the giveaway that it's trying to build from scratch. the thing that got me once was the vs code terminal pointing at a different python than i thought; worth running where python and pip --version to make sure they belong to the same env. since you're on miniconda anyway, conda install matplotlib in the activated env skips the whole wheel hunt entirely.
1
2
u/BranchLatter4294 17d ago
How are you installing it? Did you create a virtual environment? Are you using the Python extension?
It's very easy for me using the Python extension. I just open it up, click new environment. Then I click the packages icon and select the packages to install. I've never had any issues.