After successfully installed matplotlib via the terminal (ubuntu18.04 and VM5.2.44), I could use this package smoothly in python 2.7, but not in python3. I know this should be an environment issue. Could somebody kindly point out how to set up the environment in order for me to use this package (along with some other packages) in both python 2.7 and python3?
Thanks for any suggested details here.
Related
I'm trying to display data using a pie chart in python, so i tried to install matplotlib using pip. After doing that, I tried importing matplotlib but I get an error: ModuleNotFoundError: No module named 'matplotlib'.
In the Command Prompt I typed 'pip install matplotlib' and everything appeared to be successful. This is the last line:
Successfully installed backports.functools-lru-cache-1.5 cycler-0.10.0 kiwisolver-1.0.1 matplotlib-2.2.4 numpy-1.16.2 pyparsing-2.3.1 python-dateutil-2.8.0 pytz-2018.9 six-1.12.0
I've also tried 'python -m pip install -U matplotlib', but I still get a ModuleNotFoundError.
I've tried running the input statement in both python 3 and 2, neither worked.
I've looked at various different discussions on this, and none of them seemed to help me. How can I fix this?
There are various python installed in your OS. If you install matplotlib for somewhere the python that you are using does not search, you get importing errors. You should figure out which python you want to use and where the packages it searches.
check your python path. the matplotlib should be installed in the same path with your python environment.
I guess you use an IDE to run the python. some IDE have their own python environment.
if not solved. plz introduce some details about your system、how installed etc.
I installed python 3.7 on my pc (win 10). Later I tried to install matplotlib using a pip command, it installed and matplotlib is now also inside the pip list. When I go to the lib/site-packages folder where I saved python, it clearly has matplotlib inside of it. matplolib also works when us it in my command promt after using the 'python' command. But when I wanna import it in my project in pycharm, it does not work and no module is found.
I am new to all this and this is the first module I installed for python, so I can not figure out what I am doing wrong here. The version of matplotlib I am trying to install is 2.2.3.
Thx for any help
I'm having a lot of difficulty installing matplotlib in my pipenv, I believe due to the non-python dependencies.
The error I am getting is
Python is not installed as a framework. The Mac OS X backend will not be able to function correctly if Python is not installed as a framework. See the Python documentation for more information on installing Python as a framework on Mac OS X. Please either reinstall Python as a framework, or try one of the other backends. If you are using (Ana)Conda please install python.app and replace the use of 'python' with 'pythonw'. See 'Working with Matplotlib on OSX' in the Matplotlib FAQ for more information.
This is on MacOS X (High Sierra). I have installed libpng freetype and pkg-config via brew, but this does not seem to resolve the issue.
My hope for this pipenv is for it to be deployed to Heroku, if that makes any difference.
I resolved this error by following the instructions in this answer while also using this document to find where the matplotlibrc file is located.
To do this inside my pipenv I ran the following code:
python
>>> import matplotlib
>>> matplotlib.matplotlib_fname()
Using the output I navigated to the matplotlibrc file within my virtual environment and added backend: TkAgg to the file.
This resolved my issue. Hopefully this question can be of help to others!
Before trying as #brian suggested, for me, it worked by just adding matplotlib.use('TkAgg') after import matplotlib and before from matplotlib import pyplot
import matplotlib
matplotlib.use('TkAgg')
from matplotlib import pyplot
Environment
This is on MacOS X (High Sierra)
Python 3.7 version
pipenv, version 2018.7.1
I have recently started using Python 3.5 and Anaconda on my Windows pc. I am trying to plot a map. However, When I am in my Jupyter notebook and i type the command
import mpl_toolkits.basemap
I get an error message saying 'no module name' 'mpl_toolkits.basemap'
However, I have the module downloaded and in the same C:\Users\Geena file as my .matplotlib, .ipython, .jupyter files, etc.
Anyone know how I can fix this?
I've had this issue with anaconda on my windows 7.
I found the way to fix it with python 3.5:
You need to run with administrator rights "Anaconda Prompt" and in "Anaconda Prompt" run following command:
conda install -c conda-forge basemap-data-hires=1.0.8.dev0
, it will show new packages that you need to install and will ask you to install it - say 'Yes'.
After that new packages will be installed and the issue "import mpl_toolkits.basemap" will be fixed.
Thank you.
Currently, basemap is not compatible with python 3 for windows users. So, if you try conda install basemap and you have python 3 installed in windows, you'll see a message pointing out that a conflict was found with python 3.
I solved this by installing a python 2.7 environment. Try this:
http://conda.pydata.org/docs/py2or3.html
Then you just activate the python 2 environment. For example: activate py27 (py27 is the identifier of my python 2.7 environment).
After that, you can run conda install basemap with no conflict.
I'm using python 3.6.4 on Windows 7 Family Premium (32bit).
Because I was a bit frustrated by the message "no module named 'mpl_toolkits.basemap'", I searched for and tried a dozen of solutions without success : various versions, building from source, problems with VS version, nmake, ... You all know what I mean ;-)
I finally found a quite simple solution that works perfectly well for me :-) Here it is !
from here I downloaded basemap‑1.1.0‑cp36‑cp36m‑win32.whl
I changed the current dir to my download dir
I installed the wheel with python -m pip basemap‑1.1.0‑cp36‑cp36m‑win32.whl
I did the same for matplotlib‑2.2.3‑cp36‑cp36m‑win32.whl
You DO read the versions correctly : matplotlib 2.2.3 and basemap 1.1.0
Everything works fine for me and I finally can plot OSM POI's on a map of Belgium, without any 'trickery' at import :
import requests # to fetch OSM data
import json # to get the response
from mpl_toolkits.basemap import Basemap # ... Belgium is there !
import numpy as np # for arrays
import matplotlib.pyplot as plt # to build the populated map
Big big thanks to Christoph Gohlke (Danke Dir Christoph !) who did all the wonderful job !
When you have Anaconda, you don't download modules anywhere. In your command prompt, you type
conda install basemap
and it is installed with all its dependencies.
Anaconda requires an unusual install command for basemap 1.0.7.
https://anaconda.org/anaconda/basemap
To install this package with conda run:
conda install -c https://conda.anaconda.org/anaconda basemap
I just had this issue as well. All you need to do is update matplotlib by doing the following:
pip install --upgrade matplotlib
mpl_toolkits is part of matplotlib and just needs to be updated.
If you're using anaconda, the easiest thing to do is described here: in the conda prompt (as admin), type conda install -c anaconda basemap.
For people of the future : "Basemap is deprecated in favor of the Cartopy project."
https://matplotlib.org/basemap/users/intro.html#cartopy-new-management-and-eol-announcement
I've just installed Python 3.5 to experience its functionality. The problem is that all the modules I use in my daily programming have been installed and run very well on it except Matplotlib. I installed it via pip and never faced any errors while installing, but when I wanted to import it, the error saying, DLL load failed: The specified module could not be found. popped up.
What's the matter with Python 3.5, or Matplotlib?
Uninstall the module using pip uninstall matplotlib then install it again using http://matplotlib.org/downloads.html
Obtain the .exe file that best fits your machine, in my case it would be matplotlib-1.4.3.win-amd64-py3.4.exe. This will be a more complete version of matplotlib for windows rather than using pip.
I would also consider rolling back to Python 3.4 unless you absolutely need 3.5. There shouldn't be a compatibility issue between 3.4 and 3.5 for Python, but as far as matplotlib it's been tested with 3.4, but if you run through problems on 3.5 I would roll back.
If you have Python 3.5 you should install MS's Redistributable DLLs to make matplotlib working on Windows... In my case, no need to reinstall matplotlib even...
Try this example without. If error appears install that and try with it (you must log in MS site and download version for arch you using - i tested x86 only, Windows 7, Python 3.5).
That case is included in matplotlib install documentation!
Remember, you should always read documentation before you ask!