AttributeError: module matplotlib has no attribute _tri - python

I am trying to use Matplotlib in my conda environment (Python 3.6) I am getting this error. Does anyone have an idea how to fix this?
import matplotlib.pyplot as plt
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
....
C:\ProgramData\Anaconda3\lib\site-packages\matplotlib\tri\triangulation.py in <module>()
4 import six
5
----> 6 import matplotlib._tri as _tri
7 import matplotlib._qhull as _qhull
8 import numpy as np
AttributeError: module 'matplotlib' has no attribute '_tri'
Please let me know if I need to post more details of the error.

I feel like you have mismatched binaries, unfortunately, I can't reproduce your error because mine works.
(1): Perhaps try to uninstall matplotlib and then re-install it again
conda uninstall matplotlib
conda install matplotlib
(2) try the output conda list and conda info then analyze it or post it here maybe so we can analyze it?
(3) Try the following commands maybe they will work:
conda update --all
(4) if this doesn't work uninstall Anaconda maybe and try to reinstall the latest version of it.

Related

no module named error after installing with pip

I am trying to import matplotlib library, which I have installed via cmd: pip install matplotlib. And it installed successfully. But when I try to import matplotlib in jupyter lab, it gives me an error:
---------------------------------------------------------------------------
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-15-9738723f2bbd> in <module>
----> 1 import matplotlib as plt
2 from matplotlib import pyplot as pllt
ModuleNotFoundError: No module named 'matplotlib'
I checked both my python files and the installed matplotlib are in the same directory. Any ideas whats's wrong?
Sometimes happens that pip is installing the module for older python versions. Try to reinstall using pip3
Edit: as pointed out by MattDMo, on Windows they are both installed in the same folder. However, leaving this answer as this might be an issue in Linux.

AttributeError: module 'seaborn' has no attribute 'lineplot' - already updated to 0.9.0

I need help with getting lineplot running. I've already updated conda and Seaborn using pip and conda.
Any suggestions on how to resolve this? I am using Jupyter w/ Python 3.
AttributeError Traceback (most recent call last)
<ipython-input-4-5086873db64c> in <module>()
----> 1 rawx = sns.relplot(x="Timestamp",y="X0",kind="line",data=raw)
AttributeError: module 'seaborn' has no attribute 'relplot'
Sorry, based on what you have given, can only think of checking version of seaborn with:
pip freeze | grep seaborn
pip3 freeze | grep seaborn
And try this within the conda environment:
pip3 install seaborn==0.9.0
Or:
conda install seaborn==0.9.0
and to make sure you are actually loading the proper version of Python that has the updated seaborn.

ModuleNotFoundError Despite being Installed

I'm having trouble loading a package that is installed in my environment and have no idea why..
conda list
fbprophet 0.3.post2 py36_0 conda-forge
When I request for libraries installed in conda, it clearly shows that I have fbprophet installed. Now, when I import it, a ModuleNotFoundError exception is thrown.
from fbprophet import Prophet
---------------------------------------------------------------------------
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-1-83be6864a7aa> in <module>()
----> 1 from fbprophet import Prophet
2 import numpy as np
3 import pandas as pd
ModuleNotFoundError: No module named 'fbprophet'
Has anybody run into this issue? What can I do to troubleshoot this?
My suggestion would be creating a virtual environment for your python first, then conda install your package in the virtual environment.
My script was reading from my pip install list where the module fbprophet did not exist. I went back and installed it there and everything worked. Lesson learned.
Always check where your libraries are being read from.
You may have more than one Python installation. Thus you might installed the library in one Python installation and tried to call it from another one. Please let me know if you have more than one Python installation by printing the result os this CMD command where python.

Failing to import numpy in Jupyter

First bear with me as I am relatively new to coding. I am trying to import numpy to Jupyter (localhost, webbased) using Python 3 and getting an error.
import numpy as np
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-7-0aa0b027fcb6> in <module>()
----> 1 import numpy as np
ModuleNotFoundError: No module named 'numpy'
What should I do? Many thanks.
Maybe try download Anaconda and using that as your interpreter. Pretty sure that comes preinstalled with Numpy.
Or check that you are following the correct way for installing the python 3 version: think this might help: Install numpy on python3.3 - Install pip for python3
have you tried !pip install numpy in hte python Notebook cell?
I had the same problem despite correct version of Python and numpy on my Ubuntu. Then I tried something that worked in Google Colab:
!pip install numpy
After that I was able to import numpy without further complications.

Anaconda cannot import scipy

Importing scipy in iPython gave me:
In [1]: import scipy
-----------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-1-4dc45f4c0083> in <module>()
----> 1 import scipy
/usr/local/lib/python2.7/site-packages/scipy/__init__.py in <module>()
/usr/local/lib/python2.7/site-packages/scipy/_lib/_ccallback.py in <module>()
ImportError: cannot import name _ccallback_c
In [2]:
Did a complete update of all the files of Anaconda
> conda update --all
and the error remains. Did a complete search on the web and there are similar problems but without solutions. Can you help me?
i am giving you two solutions which might work by my expereince
1. create a virtualenv and install the scipy package in that virtualenv and give path like this
import sys
sys.path.append('/home/shashi/.virtualenvs/venv/lib/python2.7/site-packages/')
import scipy
2.
Download the source code https://github.com/scipy/scipy/archive/v0.18.0-1.zipand unpack it. Open a command window in the folder where the setup.py of the module is located and type
scipy python setup.py install
It looks like scipy is not installed
conda install -c anaconda scipy
Try this and let us know if you receive the error again
Cheers!

Categories

Resources