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)
Related
I'm trying to implement running machine learning on my web.
I set my Xampp addhandler .py so that can handle python files.
Basically, I checked everything python works on my web.
But the problem is that cannot import any libraries such as cv2, easyocr, and imutils.
#!C:\Users\parkc\AppData\Local\Programs\Python\Python310\python.exe
print("Content-type: text/html\n")
import cv2
import numpy as np
import imutils
import easyocr
from matplotlib import pyplot as plt
print("Hello World")
And this is my result page,
result page
Nothing shows.
So, what I doubt is that it can't load libraries from localhost.
Because if I set the code like,
#!C:\Users\parkc\AppData\Local\Programs\Python\Python310\python.exe
print("Content-type: text/html\n")
print("Hello World")
import cv2
import numpy as np
import imutils
import easyocr
from matplotlib import pyplot as plt
Then, it prints Hello World very well!
I'm googling for 2 days to solve this problem. But totally cannot get what's the problem.
Is it not possible to use package libraries on web?
My web server is Apache Xampp.
Maybe you would like to read this, it will help you a lot I think:
the article
“How to Easily Run Python Visualizations On a Web Browser with PyScript”
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.
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 am trying to install scitools with the hope of being able to use Easyviz. I installed scitools for windows as suggested in the first link. However, when I type from scitools.std import * into python I get the following error message:
ImportError: No module named oldnumeric.mlab
numpy import failed!
see doc of scitools.numpytools module for how to choose Numeric instead
This was discussed here and categorized as fixed, however I don't see how I can make this work or how to fix it. Is there something I am supposed to do to make this work?
I encountered the same issue on Ubuntu 16.04 LTS. However, such issue was not found on Trisquel GNU Linux.
The solution which I found by randomly testing was -
Do not import scitools. Just import numpy.
As an example if you were to write -
from scitools.std import *
simply do -
import numpy as np
and use numpy libraries. For plotting use matplotlib that will solve this issue.
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()