Anaconda2 ImportError: No module named matplotlib.pylab - python

In Eclipse, I tried import "matplotlib", but it didn't work.
Traceback (most recent call last):
File "C:\Users\Hunter-\Desktop\A_Cognitive\neural_network\step_function.py",
line 2, in <module>
import matplotlib.pylab as plt
ImportError: No module named matplotlib.pylab
mycode is below
import numpy as np
import matplotlib.pylab as plt
def step_funtion(x):
return np.array(x>0,dtype=np.int)
x=np.arange(-5.0,5.0,0.1)
y=step_funtion(x)
plt.plot(x,y)
plt.ylim(-0.1,1.1)
plt.show
※I checked by Windows cmd "WHERE", and finally I gets result of exsist of matplotlib's file.↓
  >WHERE /r C:\ProgramData\Anaconda2 matplotlib.* _  
C:\ProgramData\Anaconda2\pkgs\anaconda-navigator-1.9.2-py27_0\Lib\site-
packages\anaconda_navigator\static\images\logos\matplotlib.png
C:\ProgramData\Anaconda2\pkgs\matplotlib-2.2.3-py27h263d877_0\Lib\site-
packages\matplotlib\mpl-data\images\matplotlib.pdf
C:\ProgramData\Anaconda2\pkgs\matplotlib-2.2.3-py27h263d877_0\Lib\site-
packages\matplotlib\mpl-data\images\matplotlib.png
C:\ProgramData\Anaconda2\pkgs\matplotlib-2.2.3-py27h263d877_0\Lib\site-
packages\matplotlib\mpl-data\images\matplotlib.ppm
C:\ProgramData\Anaconda2\pkgs\matplotlib-2.2.3-py27h263d877_0\Lib\site-
packages\matplotlib\mpl-data\images\matplotlib.svg
C:\ProgramData\Anaconda2\pkgs\spyder-3.3.1-py27_1\Lib\site-
packages\spyder\images\matplotlib.png

I think you meant:
import matplotlib.pyplot as plt

Related

ImportError: cannot import name '_docstring' from partially initialized module 'matplotlib' (most likely due to a circular import)

I am trying to import matplotlib in .ipynb file but its not working, none of my files have the same name as _docstring yet I get this error and if I try something in .py file, it works fine.
import numpy as np
import matplotlib.pyplot as plt
import cv2 as cv
I'm running this in a .ipynb file in VS Code
Output :
ImportError Traceback (most recent call last)
Cell In[3], line 2
1 import numpy as np
----> 2 import matplotlib.pyplot as plt
3 import cv2 as cv
File c:\Users\P****\AppData\Local\Programs\Python\Python38\lib\site-packages\matplotlib\__init__.py:113
109 from packaging.version import parse as parse_version
111 # cbook must import matplotlib only within function
112 # definitions, so it is safe to import from it here.
--> 113 from . import _api, _version, cbook, _docstring, rcsetup
114 from matplotlib.cbook import sanitize_sequence
115 from matplotlib._api import MatplotlibDeprecationWarning
ImportError: cannot import name '_docstring' from partially initialized module 'matplotlib' (most likely due to a circular import) (c:\Users\P****\AppData\Local\Programs\Python\Python38\lib\site-packages\matplotlib\__init__.py)
But if I try to import matplotlib in .py file like
import matplotlib.pyplot as plt
import numpy as np
x = np.arange(1,10,0.1)
y = x**2
plt.plot(x,y)
plt.show()
It runs fine, no issues.
Try deleting matplotlib folder and reinstalling it.
Full path: AppData\Roaming\Python\Python39\site-packages\matplotlib
It worked for me.

Edit file traffic.conf with NM directory

can someone help me?
This is my code:
import traffic
from traffic.core import Traffic
import pickle
import pandas as pd
import numpy as np
import os
from numpy import sqrt, argmax
from matplotlib import pyplot
import matplotlib.pyplot as plt
from traffic.data import SO6
import math
from geographiclib.geodesic import Geodesic
from traffic.data import nm_airspaces
#BBDD INITIAL
geod = Geodesic.WGS84
bbdd_initial=SO6.from_file('initial.so6')
bdx_so6 = bbdd_initial.inside_bbox(nm_airspaces['LSAZM456'])*
And, when I run it, it gives me an error and I don't know how to fix it:
*RuntimeError Traceback (most recent call last)
<ipython-input-66-f276e3cdb85c> in <module>
bbdd_inicial=SO6.from_file('initial.so6')
bdx_so6 = bbdd_inicial.inside_bbox(nm_airspaces['LSAZM456'])
~\anaconda3\envs\AISAenv\lib\site-packages\traffic\data\eurocontrol\ddr\airspaces.py in
__getitem__(self, name)
if not self.initialized:
self.init_cache()
list_names = self.airspaces.get(name, None)
~\anaconda3\envs\AISAenv\lib\site-packages\traffic\data\eurocontrol\ddr\airspaces.py in
init_cache(self)
if self.nm_path is None:
raise RuntimeError(msg)
are_file = next(self.nm_path.glob("Sectors_*.are"), None)
RuntimeError: Edit file C:\Users\Usuario\AppData\Local\traffic\traffic\traffic.conf with NM
directory
I am trying to obtain the trajectory which is within a sector. If that doesn´t have solution, is there any way to get that?

Python error: No module named 'matplotlib.pylot' even though it is installed

I am trying to run a .py script on my Manjaro box and I keep getting the following error:
[keithm#home2 python]$ python3 gspppff.py
['/home/keithm/bin/python', '/usr/lib/python38.zip', '/usr/lib/python3.8', '/usr/lib/python3.8/lib-dynload', '/home/keithm/.local/lib/python3.8/site-packages', '/usr/lib/python3.8/site-packages']
Traceback (most recent call last):
File "gspppff.py", line 7, in <module>
import matplotlib.pylot as plt
ModuleNotFoundError: No module named 'matplotlib.pylot'
Here's the script:
#!/usr/bin/python
import datetime as dt
import sys
print(sys.path)
import matplotlib.pylot as plt
from matplotlib import style
import pandas as pd
import pandas_datareader.data as web
# graph style
style.use('ggplot')
start = dt.datetime(2020, 1, 1)
end = dt.datetime.now()
# dataframe
df = web.DataReader("TSLA", 'morningstar', start, end)
print(df.head())
I included print(sys.path) to see where python was looking for the mods and I made sure matlablib was installed in both locally: /home/keithm/.local/lib/python3.8/site-packages and in /usr/lib/python3.8/site-packages, but still no change.
The package name is "pyplot", not "pylot". Here is the corrected code:
import matplotlib.pyplot as plt
It's spelled "pyplot", not "pylot".
import matplotlib.pyplot as plt
try "pyplot" you have incorrect spelling

Python Error ImportError: No module named skimage.io

When I run this program in Python, it show me this error:
ImportError: No module named skimage.io.
I have already run the command pip install scikit-image, but I still get this error. Can you please help me?
This is my code:
import matplotlib.pyplot as plt
import skimage.io as io
import skimage.color as color
parrots = io.imread('C:\Python27\Example\parrots.bmp')
parrots_hsv= skcolor.convert_colorspace(parrots, 'RGB','HSV')
fig, ax= plt.subplots(nclos = 2, figsize=('8,4'))
ax[0].imshow(parrots)
ax[0].set_title('original image')
restored_image =skcolore.convert_colorspace(parrots_hsv, 'HSV','RGB')
ax[1].imshow(restored_image)
ax[1].set_title('restored image')
plt.show()`enter code here`
I reproduced this error like so:
import math.sqrt as sq
print(sq(4))
Error:
File ".\Solution.py", line 1, in <module>
import math.sqrt as sq
ModuleNotFoundError: No module named 'math.sqrt'; 'math' is not a package
repaired by:
from math import sqrt as sq
print(sq(4))
So I presume if you changed your imports to the below code it might fix it:
from matplotlib import pyplot as plt
from skimage import io as io
from skimage import color as color
In addition, you might want to read a bit here for a simple explanation about imports.

Matplotlib error "cannot import name pyplot" on Ubuntu

I am trying to run this code.
import numpy as np
import cv2
from matplotlib import pyplot as plt
img = cv2.imread('games.jpg',0)
plt.imshow(img, cmap = 'gray', interpolation = 'bicubic')
plt.xticks([]), plt.yticks([])
plt.show()
But I keep getting this error
Traceback (most recent call last):
File "mpl.py", line 3, in <module>
from matplotlib import pyplot as plt
File "/home/megha/matplotlib.py", line 3, in <module>
from matplotlib import pyplot as plt
ImportError: cannot import name pyplot
I googled a solution for this but I am only getting that the matplotlib version needs to be upgraded. I tried that too, and its still showing the same error.
I have also tried
import matplotlib.pyplot as plt but I have python 2.7 version, so that didnt work either.
Use import matplotlib.pyplot as plt instead.

Categories

Resources