it's my first post, hope to not break something :).
On windows there are two versions of python2.7, 32 bit and 64 bit both with pyqt and qwt5
i'm trying pyqt from some week, today i tried to use my python/pyqt/pyqwt code written on linux, on windows, but the prompt says:
C:\Users\bomba\Desktop\conversione_python\guibms>python-32 interfaccia_mark3.2.p
y
Traceback (most recent call last):
File "interfaccia_mark3.2.py", line 14, in <module>
from PyQt4.Qwt5.qplt import *
File "C:\Python27-32bit\lib\site-packages\PyQt4\Qwt5\qplt.py", line 95, in <mo
dule>
Y1 = Left = QwtPlot.yLeft
NameError: name 'QwtPlot' is not defined
someone could explain me this?
I would really apppreciate
You haven't defined the Qwtplot object.
Try using:
import PyQt4.Qwt5 as Qwt
plot = Qwt.QwtPlot()
and then use the plot object as you wish.
Related
I'm exploring the Face API. I'm using a GUI sample.
GUI link: https://github.com/Microsoft/Cognitive-Face-Python
This error occurs when I run the sample:
Traceback (most recent call last):
File "D:\Tin Central\programming\DOAN\Cognitive-Face-Python-
master\Cognitive-Face-Python-master\sample\view\__init__.py", line 101, in
OnInit
frame = MyFrame(None)
File "D:\Tin Central\programming\DOAN\Cognitive-Face-Python-
master\Cognitive-Face-Python-master\sample\view\__init__.py", line 80, in
__init__
self.book = MyLabelBook(self)
File "D:\Tin Central\programming\DOAN\Cognitive-Face-Python-
master\Cognitive-Face-Python-master\sample\view\__init__.py", line 31, in
__init__
subscription_panel = SubscriptionPanel(self)
File "D:\Tin Central\programming\DOAN\Cognitive-Face-Python-
master\Cognitive-Face-Python-master\sample\view\panel_subscription.py", line
42, in __init__
subgridsizer = wx.GridSizer(rows=2, cols=2)
TypeError: GridSizer(): arguments did not match any overloaded call:
overload 1: 'rows' is not a valid keyword argument
overload 2: 'rows' is not a valid keyword argument
overload 3: not enough arguments
overload 4: not enough arguments
You probably installed wxPython 4, which is still in beta.
You need to install wxPython 3.0.2 by going here: https://sourceforge.net/projects/wxpython/files/wxPython/3.0.2.0/.
Make sure you pick the .exe corresponding to the Python version you have (32-bit or 64-bit).
The full instructions to run the sample app are here.
I'm taking a course in Python, and the current assignment is to convert a previous assignment written in Python 2 (which used wxPython) to Python 3 (which needs Phoenix). I successfully installed Phoenix, and in the Py3 shell I can now import wx just fine. However, if I try to run my actually script, it immediately gets this error:
Traceback (most recent call last):
File "C:\Python27\transferdrillPy3.py", line 10, in
class windowClass(wx.Frame):
NameError: name 'wx' is not defined
What's up with that?
I tried going through my code and deleting every single "wx.", and now it works. I guess Phoenix doesn't need that.
Hey guys I've been cleaning up my old code, and I somehow have problems with declaration of ftplib in except block.
Traceback (most recent call last):
File "PiFtp2.py", line 57, in <module>
except ftplib.all_errors:
NameError: name 'ftplib' is not defined
Here is the Code (the entire code because I have no idea where the problem is):
Link to GitHub
PS: I'd appreciate if someone could tell me how to show code properly on stackoverflow as well :)
In the beginning of the file you imported only the ftp function from ftplib.
Instead of
from ftplib import FTP
use
import ftplib
and then change all FTP function calls from FTP(...) to ftplib.FTP(...) (line 51)
on my Raspberry Pi, I encounter a strange behaviour regarding the use of the PiCamera module.
The following code runs smoothly when either started from IDLE (F5) or from the command prompt ($python test.py)
import picamera
if __name__ == "__main__":
camera=picamera.PiCamera()
camera.close()
But when I put the camera object into a class the code will run only when started from IDLE (F5):
import picamera
class VF:
def __init__(self):
self.camera = picamera.PiCamera()
def __del__(self):
self.camera.close()
if __name__ == "__main__":
myvf = VF()
When I start the above code from the command prompt, I get the following error message:
mmal: mmal_vc_component_enable: failed to enable component: ENOSPC
Traceback (most recent call last): File "test.py", line 14, in
myvf = VF()
File "test.py", line 6, in init
self.camera = picamera.PiCamera()
File "/usr/lib/python2.7/dist-packages/picamera/camera.py", line
379, in init
camera_num, self.STEREO_MODES[stereo_mode], stereo_decimate)
File "/usr/lib/python2.7/dist-packages/picamera/camera.py", line
505, in _init_camera
prefix="Camera component couldn't be enabled")
File "/usr/lib/python2.7/dist-packages/picamera/exc.py", line 133,
in mmal_check
raise PiCameraMMALError(status, prefix)
picamera.exc.PiCameraMMALError: Camera component couldn't be enabled:
Out of resources (other than memory)
The camera module is working correct, I just stripped the code down to the least possible size. Does anybody know this problem, or a similar problem, and can probably provide a solution? The Python Version is 2.7 and the Raspberry Rasbiab-System is completely up to date.
Thanks in advance.
I struggled with this one for hours, and kept getting the "out of resources" error. I finally figured out that in my take-the-picture function, I needed to make sure I did it like this:
camera = PiCamera()
(...camera settings here...)
camera.capture(myfileName)
camera.close()
If I didn't do the close(), I'd get that error every time.
So make sure that camera.close() is getting called right after the 'snap'. It solved the problem for me.
Found out, that the camera-module is not properly shut down when the destructor is not explicitly called (had LED turned off, so didn't see this).
IDLE handles a running camera by somehow resetting it before the script starts, but not the python interpreter.
So everything is ok now when the destructor is called before the script ends.
I am trying to use Stanford POS Tagger in NLTK but I am not able to run the example code given here http://www.nltk.org/api/nltk.tag.html#module-nltk.tag.stanford
import nltk
from nltk.tag.stanford import POSTagger
st = POSTagger(r'english-bidirectional-distim.tagger',r'D:/stanford-postagger/stanford-postagger.jar')
st.tag('What is the airspeed of an unladen swallow?'.split())
I have already added environment variables as
CLASSPATH = D:/stanford-postagger/stanford-postagger.jar
STANFORD_MODELS = D:/stanford-postagger/models/
Here is the error I keep getting
Traceback (most recent call last):
File "D:\pos_stanford.py", line 4, in <module>
st = POSTagger(r'english-bidirectional-distim.tagger',
r'D:/stanford-postagger/stanford-postagger.jar')
... LookupError: NLTK was unable to find the english-bidirectional-distim.tagger file! Use software specific configuration paramaters or set the STANFORD_MODELS environment variable.
Some forums suggest that
File "C:\Python27\lib\site-packages\nltk\tag\stanford.py", line 45, in __init__
env_vars=('STANFORD_MODELS'), verbose=verbose)
should be changed so that there is a comma in
env_vars=('STANFORD_MODELS',), verbose=verbose)
but it doesn't solve the problem either.
Please Help me in solving this issue.
Other Information:
I am using
Windows 7 64 bit
Python 2.7 32 bit
NLTK 2.0
Note : Just posting it as answer to help in case others face this issue in future
I finally found out what I did wrong.. it turned out to be a blunder.
Tagger file name is not 'english-bidirectional-distim.tagger'
but 'english-bidirectional-distsim.tagger'.