from skimage import io
photo=io.imread('myimage.jpg')
print(type(photo))
photo.shape
print(photo.shape)
import matplotlib.pyplot as plt
plt.imshow(photo)
This is my code on my editor. I don't use anacona distribution or jupyter notebook. print(type(photo)) and print(photo.shape) lines works but plt.imshow(photo) doesn't.How to fix it? Though ,I have installed those necessary modules and packeges.
My second question , is there another python distribution which is so efficient like anaconda.
Related
Hi I am having a little trouble with the module spectrogram which I need to use in order to create spectrograms from my wav files.
I repeatedly get the error message No module named spectrogram when importing on my Windows which is running Python version 2.7.12. In contrast when importing the module on my mac which runs version 2.7.11 I have no problems. I can't find anything that suggests that this is a version specific problem and was hoping someone might be able to help me fix this.
Here is the code I am using to import the needed modules. This runs absolutely fine on my mac, but won't run on Windows.
import glob
import numpy as np
import scipy.io import wavfile
import spectrogram as sp
import os
import matplotlib.pyplot as plt
Spectrogram is a part of scipy, you must make that known.
from scipy import signal
signal.spectrogram(bla,bla,bla)
I am currently in PyCharm and I have the following line of code:
import cv2
Nonetheless, it gives me the error No module named cv2
I went to Preferences > Project Interpreter > + then found and downloaded cv2 just fine. In the Project Interpreter it lists cv2 as installed. I am not sure why it still shows that the module doesn't exist. Is there some way to download cv2 via command line. I am on OS X 10.10.
Here is the code I have so far (all the other imports work just fine):
# Program for OCR
import numpy as np
import cv2
from matplotlib import pyplot as plt
I find that sometimes after installing a module in PyCharm it requires a restart in order for it to work. Also, if you do want to do it in the command line, try pip3 install cv2.
I'm trying to run a basic matplotlib script to ensure that everything is working. The program is as follows:
import numpy as np
import matplotlib.pyplot as plt
x=np.arrange(0,5,0.1);
y=np.sin(x)
plt.plot(x,y)
But when I run "python a.py" in the terminal I am getting the error
that the numpy module has no attribute 'arrange'.
I uninstalled numpy and matplotlib and reinstalled them. First numpy, then matplotlib through the ubuntu repository but I am still getting this error. I can't figure out what is wrong. Am I getting an incomplete installation or something? I am using Ubuntu 14.04.
The method name is arange, not arrange.
Also, after using plt.plot(...), you need to call plt.show() to draw the plot.
I want to plot some GPS-data using python 2.7 using matplotlibs basemap.
I download the binary windows installer and it executes and run without any problems. However, when I try to import and run in python I get:
from mpl_toolkits.basemap import basemap
ImportError: No module named basemap
I tried the
python setup.py
and
pip install basemap-1.0.8-cp27-none-win_amd64
in prompt which seems to be succesful.
GEOS, which is a dependency should be involved in the Basemap installer but I installed OSGeo4w64 separately to make sure geos_c and init is in place.
I hope someone can help me out. This feels like it is well above my level.
I have ofcourse looked through other threads on this page, but none of them seem to offer a solution.
Best regards
Instead of this:
from mpl_toolkits.basemap import basemap
do this:
from mpl_toolkits.basemap import Basemap
Check this as well.
I seem to have a problem that is in parts very similar to the one mentioned here:
Python with eclipse import problem
But unfortunatly just in parts otherwise that would have solved mine as well.
I use Eclipse SDK, Version: 3.7.0 with PyDev 101.
Furthermore I have installed
numpy-1.6.1rc1-win32-superpack-python2.6.exe
and
matplotlib-1.0.1.win32-py2.6.exe
as noted here:
http://matplotlib.sourceforge.net/users/installing.html
I have rebuild all the packages and looks the site-packages are listed.
(by the way as you see it is an Python version installed with ArcGIS )
If I test a script for instance a very simple one like:
import numpy
import matplotlib
import pylab as pl
I get the following error in Eclipse:
import matplotlib
import pylab as pl
from matplotlib.pylab import *
ImportError: No module named pylab
Even though the interpreter for Pydev is pointing to the appropriate version of python and matplotlib is installed properly in there (site-packages) it does not work in Eclipse. In iPython it works perfect.
What still needs to be done to get matplotlib work in Eclipse?
Thanks a lot!
Werner
pylab is in matplotlibs namespace, so this should work:
import matplotlib.pylab as pylab
I found that turning off interactive move and then calling show worked.
import matplotlib.pyplot as plt
#...your code...
plt.ioff()
plt.show()