My platform:
Ubuntu 13.04, Python 2.7.4.
Installing matplotlib failed, ImportError: No module named pyplot.
I have tried many ways such as
$ sudo apt-get install python-matplotlib
and easy install, install from source..., I'm folllowing http://matplotlib.org/faq/installing_faq.html
But none of them works, This ImportError always happen, Anyone can help?
EDIT The trace back:
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-4-82be63b7783c> in <module>()
----> 1 import matplotlib
/home/wuhuijia/matplotlib.py in <module>()
1 import numpy as np
----> 2 import matplotlib.pyplot as plt
3 import scipy.optimize as so
4
5 def find_confidence_interval(x, pdf, confidence_level):
ImportError: No module named pyplot
Your script is named matplotlib.py. Python will first look locally when importing modules, that is, on the directory itself. Thus, Python imports your script (and not the installed matplotlib) when you execute import matplotlib.pyplot, and since your script has no submodule pyplot, it fails.
Rename your script to something else (e.g., testmpl.py) and you should be fine.
Related
I get an error when I import the emoji into my Jupyter notebook.
This is the error I'm getting.
ModuleNotFoundError Traceback (most recent call last)
/var/folders/8v/gry0pxmn7tq64rhkjv504zr00000gn/T/ipykernel_12578/2329533640.py in <module>
2 import pandas as pd
3 import numpy as np
----> 4 import emoji
5 from collections import Counter
6 import matplotlib.pyplot as plt
ModuleNotFoundError: No module named 'emoji'
I am using MacOs. How do I solve this?
Did you install the library?
For the installation process via pip:
pip install emoji --upgrade
or via git:
git clone https://github.com/carpedm20/emoji.git
cd emoji
python setup.py install
That being done, you can import emoji into your code.
For further information you can read the installation process on the documentation here.
I installed Python and Jupyter through Anaconda. I tried to reinstall Matplotlib and, after this, probably this installation created some error when I try to import Matplotlib. Always when I try to import Matplotlib I have the error below.
---------------------------------------------------------------------------
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-15-a0d2faabd9e9> in <module>
----> 1 import matplotlib.pyplot as plt
ModuleNotFoundError: No module named 'matplotlib'
I tried installing Matplotlib again through the Anaconda Navigator. I open it\ go to 'Environments'\ base(root)\ all.
Then, I select Matplotliband click 'Apply'. It does the installation. But afterwards, Matplotlib is still giving the same error.
import matplotlib.pyplot as plt
---------------------------------------------------------------------------
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-16-a0d2faabd9e9> in <module>
----> 1 import matplotlib.pyplot as plt
ModuleNotFoundError: No module named 'matplotlib'
I would expect to get the import done, and start working with Matplotlib to create plots, but I only get this error.
If you have mapped your command line interpreter to python, open command prompt (Windows) or Terminal (Mac) and type:
conda install -c conda-forge matplotlib
This will automatically install matplotlib for you. You can search other packages on https://anaconda.org/ for future downloads.
I want to load EXR images in a Python script. Thus I imported it with
import OpenEXR
but unfortunately I am getting the following error when I start my script with
ipython testscript.py
Error Message
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
PATH_TO_SCRIPT/testscript.py in <module>()
8 import numpy as np
9 # import matplotlib.pyplot as plt
---> 10 import OpenEXR
11
12 # import dts_input
ImportError: PATH_TO_SCRIPT/OpenEXR.cpython-37m-x86_64-linux-gnu.so: undefined symbol: _ZTIN7Imf_2_27OStreamE
I have installed OpenEXR with Arch Linux's package manager and the binding module for python locally with
pip install --target ./ openexr
and a file called OpenEXR.cpython-37m-x86_64-linux-gnu.so has been installed in the script folder.
I have no idea how to solve the linking problem since it seams to be a linking error relating to OpenEXR's own imf library.
My problem is very simple. I have installed it with sudo pip3 install plotly but I can't import it. I've already tried to reinstall it without effects.
ImportError Traceback (most recent call last)
<ipython-input-1-9d1f271208ac> in <module>()
----> 1 import plotly.plotly as py
2 import plotly.graph_objs as go
3 import pandas as pd
4 from pandas import Series,DataFrame
5 import numpy as np
ImportError: No module named 'plotly'
If this error occurs open Terminal and if you using different source like ZSH or something else change it to bash by running
bash
in terminal and then run
conda install -c https://conda.anaconda.org/plotly plotly
and the problem resolves.
I am using ipython when I am trying to import matplotlib.
I am getting following error
ImportError Traceback (most recent call last)
/home/akajappan/<ipython-input-4-82be63b7783c> in <module>()
----> 1 import matplotlib
/home/akajappan/matplotlib.py in <module>()
----> 1 from pylab import plotfile, show, gca
2 import matplotlib.cbook as cbook
3
4 fname = cbook.get_sample_data('msft.csv', asfileobj=False)
5 fname2 = cbook.get_sample_data('data_x_x2_x3.csv', asfileobj=False)
ImportError: No module named pylab
I tried to install scipy still the error exists.
(sudo apt-get install python-numpy python-scipy python-matplotlib)
Operating system : ubuntu 12.04
If you are satisfied with workaround - install anaconda distribution. This is a python distribution with all (or most) scientific packages installed. It saved me, it may help you as well.
http://continuum.io/downloads