matplotlib xkcd not working - python

I am trying to get the matplotlib xkcd function working, following this after installing all the necessary stuff. http://matplotlib.org/xkcd/examples/showcase/xkcd.html
every time I get this:
Traceback (most recent call last):
File "graph.py", line 4, in <module>
plt.xkcd()
AttributeError: 'module' object has no attribute 'xkcd'
(I saved the code as graph.py)
Any ideas what could be going wrong?

The xkcd module was added in matplotlib 1.3.1. You need to update your version to that to get the xkcd examples to work properly.

Related

AttributeError: module 'pyautogui' has no attribute 'locateCentreOnScreen'

I have PyAutoGUI-0.9.52 and there no file in the working directory named pyautogui. I have pillow installed, but still, it shows this error please can someone help me.
This is the full error:
Traceback (most recent call last):
File "C:\Users\Admin\Desktop\lolllll.py", line 4, in <module>
pyautogui.click(pyautogui.locateCentreOnScreen('launcher.png'))
AttributeError: module 'pyautogui' has no attribute 'locateCentreOnScreen'
If there is no solution please suggest a different module which can do this. But I would prefer to stick with this.
We can't help you without code. However, a simple google search results in the fact that you mistyped, and the function is pyautogui.locateCenterOnScreen(...), with a properly spelled center.

AttributeError: module 'seaborn' has no attribute 'heatmap'

I am fairly new to Python. I am trying to run the below code and getting Module not found error. I tried checking seaborn version and it was the latest. After multiple tries I placed my file in a different path and it started working fine. Could someone help me understand this behavior.
My Anaconda path: C:\Users\Kumar>
Placed the file in same path and it did not run.
Placed the file in Downloads and ran again from Jupyter and it worked fine. Please help in understanding what is the difference and how can I resolve these errors in future
My Code:
corr = df.corr()
plt.figure(figsize=(14,14))
plt.figure(figsize=(14,14))
sns.heatmap(corr,cmap= 'coolwarm')
AttributeError Traceback (most recent call last)
<ipython-input-15-522f105baca0> in <module>
2 plt.figure(figsize=(14,14))
3 plt.figure(figsize=(14,14))
----> 4 sns.heatmap(corr,cmap= 'coolwarm')
AttributeError: module 'seaborn' has no attribute 'heatmap'
possibly you need to install additional modules:
statsmodels
fastcluster
It works for me
see https://seaborn.pydata.org/installing.html

Using signal processing library in scipy

I want to use the signal processing library under Scipy. But running the following example code given in Scipy webpage has given me an error. I have rechecked my Scipy installation and it is the latest.
The example code I ran is as follows
from scipy import signal
import numpy as nu
b=nu.array([0.5,0.25])
a=nu.array([1.0,-1.0/3])
C=nu.array([[0,1]])
D=nu.array([[0]])
num=[1,3,3]
den=[1,2,1]
sys=signal.TransferFunction(num,den)
print sys
When I ran it, it gives:
$ python trial.py
Traceback (most recent call last):
File "trial.py", line 9, in <module>
sys=signal.TransferFunction(num,den)
AttributeError: 'module' object has no attribute 'TransferFunction'
AttributeError: 'module' object has no attribute 'TransferFunction'
This is the key phrase you want to search based on. Have you tried importing the module explicitly?
Also this could give you more information related to your problem.
Please check the scipy version you have installed, if you have an older version of scipy the TransferFunction might not be there, due to which you are seeing the AttributeError
For me your code worked fine for latest version of scipy

Facebook-sdk python module has no attribute GraphAPI

After installing the facebook-sdk module here, and looking at other solutions here and elsewhere, I keep getting this error:
Traceback (most recent call last):
File "facebook.py", line 1, in <module>
import facebook
File "/home/facebook/facebook.py", line 3, in <module>
graph = facebook.GraphAPI(access_token='ACCESS TOKEN HERE')
AttributeError: 'module' object has no attribute 'GraphAPI'
For this very simple python code to authenticate...
import facebook
graph = facebook.GraphAPI(access_token='ACCESS TOKEN HERE')
print 'Workinnnn'
It says my module is installed and up to date, and I have installed both within (as suggested) a virtualenv and outside, and still get the error. I also definitely HAVE the module in usr/local/lib/python etc. dist packages... and it contains the class GraphAPI
Has anyone got a suggestion either:
1) What might be going wrong?
2) What to try to fix it? UNinstall something?
3) If there is another way other than pip to install the module... I don't normally use pip (but definitely have it installed and installed facebook-sdk from it) so if there's another way then I'd like to try...
Cheers :/
Solution = don't name your script the same as your module.
I'm an idiot, sigh...

SciPy and NumPy on Mac OS 10.6.8

I have installed Python 2.7.2 on my Mac, and it's working fine. I downloaded the binary for SciPy (http://sourceforge.net/projects/scipy/files/scipy/0.9.0/scipy-0.9.0-py2.7-python.org-macosx10.6.dmg) and NumPy (http://sourceforge.net/projects/numpy/files/NumPy/1.6.1/numpy-1.6.1-py2.7-python.org-macosx10.6.dmg) respectively, and installed them.
However, when I tried the following, error occurred:
>>> import numpy
>>> print numpy._version_
Traceback (most recent call last):
File "<pyshell#2>", line 1, in <module>
print numpy._version_
AttributeError: 'module' object has no attribute '_version_'
However, this works fine:
>>> numpy.version.version
'1.6.1'
Since I am new to Python, I just followed on the instructions here. I wonder what may cause the error above? Thanks.
What you are looking for is numpy.__version__ with two underscores before and after the word version. By my inderstanding, that is the convention for private (or semi-private) variables in python.

Categories

Resources