ModuleNotFoundError with Spyder - python

I downloaded spyder and practicing I have tried to use commands that generate an error.
The command is as follows:
import numpy as np
from sklearn import dataset, linear_model
import matplotlib.pyplot as plt
boston = datasets, load_boston()
print(boston)
print()
and spyder says:
runcell(0, 'C:/Users/HP/.spyder-py3/temp.py')
Traceback (most recent call last):
File "C:\Users\HP\.spyder-py3\temp.py", line 9, in <module>
import matplotlib.pyplot as plt
ModuleNotFoundError: No module named 'matplotlib'
runcell(0, 'C:/Users/HP/.spyder-py3/temp.py')
Traceback (most recent call last):
File "C:\Users\HP\.spyder-py3\temp.py", line 9, in <module>
import matplotlib.pyplot as plt
ModuleNotFoundError: No module named 'matplotlib'

You should install matplotlib into spyder via the pip.exe from the spyder package.
C:\Users\Ann>cd C:\ProgramData\Anaconda3\pkgs\pip-19.2.3-py37_0\Scripts
C:\ProgramData\Anaconda3\pkgs\pip-19.2.3-py37_0\Scripts>pip install matplotlib

I was having the same issue and it was resolved after I used the CMD.exe Prompt from the Anaconda navigator on Windows 10.
Note that I already had it installed fine through the windows command prompt, outside Anaconda.

Related

Python "Import missingno" results in "ImportError: attempted relative import with no known parent package"

I am using jupyter nb running python 3.9.1 using pip to install modules etc.
All imports work smoothly except missingno.
All the modules being imported are located in the same location Python39\lib\site-packages but missingno results in Import Error.
The missingno module had been imported and it has run smoothly before but after a kernel restart, the Import Error cropped up.
ImportError Traceback (most recent call last)
<ipython-input-16-fad26a6fb4fe> in <module>
6 #Visualization
7 import matplotlib.pyplot as plt
----> 8 import missingno
9 import seaborn as sns
10 plt.style.use('seaborn-whitegrid')
~\AppData\Local\Programs\Python\Python39\Lib\site-packages\missingno\missingno.py in <module>
6 import seaborn as sns
7 import pandas as pd
----> 8 from .utils import nullity_filter, nullity_sort
9 import warnings
10
ImportError: attempted relative import with no known parent package
How to fix it?
I have tried to delete the missingno files and reinstalling it using pip install missingno but nothing works.
Running Python in shell and importing missingno, I still get the same error. There is nothing fancy in my code, a simple, generic import which showed no signs of error before kernel restart.
>>> import missingno
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Users\OK\AppData\Local\Programs\Python\Python39\Lib\site-packages\missingno\missingno.py", line 8, in <module>
from .utils import nullity_filter, nullity_sort
ImportError: attempted relative import with no known parent package
Try opening the missingno.py file in site-packages.
Change
from .utils import nullity_filter, nullity_sort
to
from utils import nullity_filter, nullity_sort

Windows: ModuleNotFoundError: No module named 'matplotlib'

I'm using Python 3.7.5 and Windows 10. I installed matplotlib via pip but now if I run:
import matplotlib.pyplot as plt
The output is:
Traceback (most recent call last):
File "C:\Users\Pol\Documents\Python\hallo.py", line 1, in <module>
import matplotlib.pyplot as plt
ModuleNotFoundError: No module named 'matplotlib'
How can I overcome this?

import matplotlib.pyplot as plt in python3.7

when i run python3.7 in pycharm(matplotlib error)
import matplotlib.pyplot as plt
then i get
Traceback (most recent call last):
File "D:/PyCharm 2017.2.3/Workplace/SimpleGA-master/ga.py", line 3, in
<module>
import matplotlib.pyplot as plt
ModuleNotFoundError: No module named 'matplotlib'
and i tried to find matplotlib in https://pypi.python.org/pypi/matplotlib,but not find python3.7 package
Make sure you have installed the matplotlib modules.
+ pip install matplotlib
Then try again.
Thanks!

ImportError: cannot import name flib

I want to use Python for trying out hddm.
I installed anaconda, Python 2.7. When I try to follow the hddm tutorial in the command line window in spyder, the following happens, which seems to be a problem in pymc:
import pandas as pd
import matplotlib.pyplot as plt
%matplotlib inline
import hddm
Traceback (most recent call last):
File "<ipython-input-24-17365318b31c>", line 1, in <module>
import hddm
File "/Users/c/anaconda/lib/python2.7/site-packages/hddm/__init__.py", line 7, in <module>
import likelihoods
File "/Users/c/anaconda/lib/python2.7/site-packages/hddm/likelihoods.py", line 2, in <module>
import pymc as pm
File "/Users/c/anaconda/lib/python2.7/site-packages/pymc/__init__.py", line 31, in <module>
from .distributions import *
File "/Users/c/anaconda/lib/python2.7/site-packages/pymc/distributions.py", line 30, in <module>
from . import flib, utils
ImportError: cannot import name flib
I work on Mac OS X 10.7. On the web, I find some comments concerning pymc possibly not being compiled with the correct version of gfortran, but the solutions all seem to be for windows. Also, I thought that this kind of problem should not happen with an integrated system like Anaconda?
There are two options:
use conda install -c conda.binstar.org/pymc pymc
install gfortran and use pip install -U pymc

How to install mathplotlib - python

I'm using sublime text 2 to run python 2.7. I have downloaded and installed mathplotlib. When I type the code:
import matplotlib.pyplot
I'm getting this error.
Traceback (most recent call last):
File "/Volumes/HP v190b/Python - Squash Coursework/squashFINAL.py", line 212, in <module>
import matplot.pyplot as plt
ImportError: No module named matplot.pyplot
Any ideas why? I'm using a Mac!
You may check the dependencies, sometimes you need to install some dependencies so that you can import certain module, take a look at this link http://matplotlib.org/users/installing.html

Categories

Resources