Why can I not run matplotlib on Python 3.10? - python

My Issue. I am trying to run matplotlib on python 3.10 on my MacOS, but I get the following error:
ModuleNotFoundError: No module named 'matplotlib'
However, when I try running
pip install matplotlib
then I get back
Requirement already satisfied: cycler>=0.10 in ./.local/lib/python3.9/site-packages (from matplotlib) (0.10.0)
Requirement already satisfied: numpy>=1.16 in ./mambaforge/lib/python3.9/site-packages (from matplotlib) (1.21.2)
Requirement already satisfied: kiwisolver>=1.0.1 in ./.local/lib/python3.9/site-packages (from matplotlib) (1.3.2)
Requirement already satisfied: pyparsing>=2.2.1 in ./.local/lib/python3.9/site-packages (from matplotlib) (2.4.7)
Requirement already satisfied: pillow>=6.2.0 in ./.local/lib/python3.9/site-packages (from matplotlib) (8.3.2)
Requirement already satisfied: python-dateutil>=2.7 in ./.local/lib/python3.9/site-packages (from matplotlib) (2.8.2)
Requirement already satisfied: six in ./mambaforge/lib/python3.9/site-packages (from cycler>=0.10->matplotlib) (1.16.0)
Also, in response to
python3 --version
terminal says
Python 3.9.6
Also, I am able to use matplotlib just fine if I compile my code using Python 2.7.16 on Sublime Text 3.
My Question. How can I get matplotlib to run on Python 3.10?
Since I am still new to Python (or to programming, for that matter), please let me know if I should provide additional information.
Note: I have already looked at this and this, but I couldn't fix the issue.

I have had the same issue. It wasn't only for MatPlotLib, but Pandas and NumPy.
From seeing what the terminal tried to do, it seems that 3rd party libraries are not "compatible" yet. I am using my older version of python now.
When trying to get the libs, it just scrolled through all the versions of matplotlib, and gave errors. It might take some time before this is resolved.

I recently experienced this problem after installing Python 3.10.
Use version Python 3.9. That worked for me, but I can't figure out how to install matplotlib on 3.9 via the command line, but I'm using PyCharm right now, so I got it to work on there.
proof of installation
If you figure out how to install it via the command line, let me know! I'm using two versions of Python. I would like to know how to do it as well. I'm sure I can find it eventually. I believe if you uninstall Python 3.10 and leave only 3.9, it will work.

I found a temporary (unstable) fix for anyone desperate to run matplotlib (and many other packages, e.g. numba, scikit-learn, scipy, etc.) on Python 3.10 for Windows 10, as described by Amit Thinks. Amit uses a source of unstable binaries curated by Christoph Gohlke at UC Irvine, so these are likely not malware infested.

I faced the same issue , while trying to install matplotlib for python 3.10 .
i faced 2 issues
1)It said wheel module not installed (installed via running pip install wheel)
2)It said it required microsoft visual c++ 14.0+ (it was already present when checked in control panel(x64)) (after installing wheel module while running the code[pip install matplotlib] for 3rd time). asked me to download visual studio community 2019 and build tools.... Did so.
And now i was able install matplotlib in python 3.10 and runs fine (when cheking in control panel there was another visual c++ 14.0+ installed (x86) along with (x64),dont know why it works only when x86 version of visual c++ is installed.

if you are using conda enviroment:
conda install -c conda-forge matplotlib

I think it does run on Python 3.10. When you are querying for a graph or plot, try doing this:
import matplotlib.pyplot as plt

I had same issues with matplotlib,pandas,numpay etc on python 3.10 on window 10.
I install with windows binaries packages.
after download "matplotlib‑3.4.3‑cp310‑cp310‑win_amd64.whl"
use this commond:
pip install matplotlib-3.4.3-cp310-cp310-win_amd64.whl

Related

ModuleNotFound Python

In my Macs Terminal I'm not able to use Python packages as I get a ModuleNotFound error. This is not the case in VS code, as I tried all kinds of things, including a venv based from a tutorial, and it seemed to work.
When I run pip install requests I get the following:
Requirement already satisfied: requests in /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages
(2.25.1)
Requirement already satisfied: chardet<5,>=3.0.2 in /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages
(from requests) (4.0.0)
Requirement already satisfied: urllib3<1.27,>=1.21.1 in /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages
(from requests) (1.26.5)
Requirement already satisfied: idna<3,>=2.5 in /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages
(from requests) (2.10)
Requirement already satisfied: certifi>=2017.4.17 in /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages
(from requests) (2020.12.5)
When I run python --version I get Python 3.9.5
I've spend hours now trying to get this "environment" up and correctly running, but with not much success.
The problem is that you have multiple Python versions installed. One possibly from the official Python website, and one through Homebrew (I'm guessing a bit). These interfere somewhat.
Here's the thing though: the "official" one didn't not install the standard python alias. It only installed the more explicit python3 command. Oddly (and confusingly) enough, it did install pip, probably alongside pip3.
When you type python, the shell will find the one installed by Homebrew; the other one doesn't not exist. When you explicitly type python3, you'll get the correct one. It looks like your PATH environment variable is set up to have the "official" installation come first, and then the Homebrew one.
So, best and easiest is to simply use python3 explicitly.
You could attempt to uninstall the Homebrew one in /usr/local/ if you want to and don't think you need it.
You could also tinker inside the /Library/Frameworks/Python.framework/Versions/3.9/bin and make an alias for python, but I wouldn't recommend it, unless you become more familiar with the shell, Python installations and your system. And after all, it's only one character more to type currently.

ModuleNotFoundError: No module named 'pandas' in vs code

When I'm trying to import pandas in vs code, I have the following error:
ModuleNotFoundError: No module named 'pandas'
I went to cmd and typed: pip3 install pandas and it got successfully installed showing following message:
Requirement already satisfied: pandas in c:\users\nitis\anaconda3\lib\site-packages (1.1.3)
Requirement already satisfied: python-dateutil>=2.7.3 in c:\users\nitis\anaconda3\lib\site-packages (from pandas) (2.8.1)
Requirement already satisfied: pytz>=2017.2 in c:\users\nitis\anaconda3\lib\site-packages (from pandas) (2020.1)
Requirement already satisfied: numpy>=1.15.4 in c:\users\nitis\anaconda3\lib\site-packages (from pandas) (1.19.2)
Requirement already satisfied: six>=1.5 in c:\users\nitis\anaconda3\lib\site-packages (from python-dateutil>=2.7.3->pandas) (1.15.0)
Please suggest what to do
There are a couple different ways that this can happen.
You are using a Python 2 Interpreter in VSCode
You are using a Python 3 installation which isn't Anaconda.
To solve this, I would recommend checking which python interpreter you are using using the following steps:
Go to View >> Command Palette >> Search for Python: Select Interpreter
Then check which interpreter you are using.
According to the information you provided, the reason is that the environment used in the lower left corner of VS Code is different from the terminal. You could use the following methods:
Method 1. Since the module "pandas" is installed in "Anaconda", please select the "conda" environment in the lower left corner of VS Code to ensure that the Python environment used is the same as that of the terminal.
Method 2. Use the shortcut key Ctrl+Shift+` to open a new VS Code terminal, it will automatically enter your currently selected Python environment (the lower left corner of VS Code). Then we can install the module "pandas" in the this environment.
check:
We can use the command "pip --version" to check the source of the module installation tool "pip", the module is installed in this location:
The command "pip show pandas" can check whether the module installation location is consistent with the Python environment displayed in the lower left corner of VS Code:
Reference: Python environment in VS Code.
Its because of PYTHONPATH issue . if you try to install pip install "module",it says that already satisfied but ,when you run the program the error occurs as modulenotFoundError In vscode, So I did uninstall the python interpreter ,and reinstall in specific path so that I can remember.
And go to environment variable ,path variable add new path ,where you installed python.exe and also add scripts and sitepackages. and also go to system variable ,path variable see if path is already added or not ,otherwise add it there too.
Restart the vscode It should work.
And I also run command in commandprompt as pip install "module".
It did work for me.

pip is only instaling to the default python instaltion how can i chnage it

i created a new project in pycharm. it created a new installation of python in a folder called myproject\vin.
pip will allways go to the default installation at
c:\\python64bit,
not c:\test\vin
example in my if i go import pandas it says that module does not exist.
if i go pip install pandas, it says
You should consider upgrading via the 'python -m pip install --upgrade pip' command.
PS C:\Users\tpottel\programming\java\eclipse projects\BBitBotCoinUsing2\untitled1\venv\Scripts> pip install pandas
Requirement already satisfied: pandas in c:\python64bit\lib\site-packages (0.25.0)
Requirement already satisfied: python-dateutil>=2.6.1 in c:\python64bit\lib\site-packages (from pandas) (2.8.0)
Requirement already satisfied: numpy>=1.13.3 in c:\python64bit\lib\site-packages (from pandas) (1.17.0)
Requirement already satisfied: pytz>=2017.2 in c:\python64bit\lib\site-packages (from pandas) (2019.2)
Requirement already satisfied: six>=1.5 in c:\python64bit\lib\site-packages (from python-dateutil>=2.6.1->pandas) (1.1
c:\python64bit is the default location
How can I change the installation pip will update? to
C:\Users\tpottel\programming\java\eclipse projects\BBitBotCoinUsing2\untitled1\venv\Scripts>
There are probably a few ways you might find more robust for managing multiple python installations on one machine such as creating a virtual environment (https://www.freecodecamp.org/news/installing-multiple-python-versions-on-windows-using-virtualenv/) but ignoring that, here's one way you could go about it.
There's two facts you'll need to know and work around for this, firstly, I think you'll need to make sure that you second python installation is added to path in order to call 'pip' from your terminal/command line.
Second is that python searches through installations in order, by finding the python.exe file. This means that with:
pip install pandas
which, it's worth nothing is shorthand for:
python -m pip install pandas
it will find the first python.exe based on a hierarchy and install to there, which is why you're not able to install to your second distribution.
If you rename the second distributions .exe to something like 'python64.exe' you can call it specifically with
python64 -m pip install pandas
hopefully that should help! Again, there might be a better way of acheiving this, but this is one method that should work.

Install pandas for Python 2.6

Currently I have two versions of python (2.6 and 2.7) on my unix machine.
Python 2.7 has already got pandas installed for it but 2.6 doesn't have.
So, I'm trying to install pandas specifically for python2.6 as my production environment has got ONLY python 2.6 and I cannot upgrade that at this point of time.
When I tried installing it using the below command, it says "Requirement already satisfied" pointing to python2.7 and nothing got added to python 2.6.
#user pip install pandas
Requirement already satisfied: pandas in /usr/local/lib/python2.7/site-
packages
Requirement already satisfied: pytz>=2011k in
/usr/local/lib/python2.7/site-packages (from pandas)
Requirement already satisfied: numpy>=1.7.0 in
/usr/local/lib/python2.7/site-packages (from pandas)
Requirement already satisfied: python-dateutil in
/usr/local/lib/python2.7/site-packages (from pandas)
Requirement already satisfied: six>=1.5 in
/usr/local/lib/python2.7/site-packages (from python-dateutil-
>pandas)
Please advice on how do I specifically install Pandas for Python2.6.
Assuming you installed Python 2.6 in the usual directory, you can just run
C:\Python26\Scripts\pip.exe
or go to that directory in a Command Prompt and run
.\pip.exe
Oops. Just noticed you're on a UNIX box. But the result is the same. You must specify the full path to the pip you want, or go to the directory and run .\pip
The other pip and python are in the system "path", the list of places that get searched for an executable. So, you have to tell the O/S exactly which pip you want to run. Otherwise, if you just say pip, it will find whichever one it can find in the system path.

Difficulties installing Networkx module properly on OSX

I want to use networkx (python 2.7.10).
Therefore I have installed networkx with pip. But when I actually tried to import it, I got this error No module named networkx
When I check pip freeze, it return networkx==1.11
Although I tried to reinstall it, it returned
Requirement already satisfied: networkx in /usr/local/lib/python2.7/site-packages
Requirement already satisfied: decorator>=3.4.0 in /usr/local/lib/python2.7/site-packages (from networkx)
I can't figure out what I should do to get it to work.
My Mac version is 10.11.6
It would be greatly appreciated if you could explain the details.
I would really not mess with your systems python.
If you are going to be doing data science work. I would suggest you get a Python distribution like Anaconda and run it inside your home directory so you don't do something you will probably regret.
It has an easy installer. The key during the install to make this problem go away is to say "YES" to changing your path.
After that you will have a nice GUI tool for installing packages.

Categories

Resources