Pyglet window=pyglet.window.Window(resizable=True) error - python

Running python 2.7.8 on OSX 10.9
I have installed and imported pyglet, but when I run
window = pyglet.window.Window(resizable=True)
It returns
Traceback (most recent call last):
File "<pyshell#3>", line 1, in <module>
window = pyglet.window.Window(resizable=True)
File "/Library/Python/2.7/site-packages/pyglet/__init__.py", line 306, in __getattr__
__import__(import_name)
File "/Library/Python/2.7/site-packages/pyglet/window/__init__.py", line 1669, in <module>
from pyglet.window.carbon import CarbonPlatform, CarbonWindow
File "/Library/Python/2.7/site-packages/pyglet/window/carbon/__init__.py", line 49, in <module>
from pyglet.window import key
ImportError: cannot import name key
What would explain such an error? I have made sure that everything is running 32 bit, and checked compatibility.
Edit: full code:
import pyglet
window = pyglet.window.Window(resizable=True)
#window.event
def on_draw():
window.clear()
pyglet.gl.glColor4f(1.0,0,0,1.0)
pyglet.graphics.draw(2, pyglet.gl.GL_LINES,
('v2i', (10, 15, 30, 35))
)
pyglet.app.run()
I fixed the previous error, I had a misnamed file... whoops...
but now I receive the error:
Traceback (most recent call last):
File "/Users/jackwoodrow/Desktop/TOK", line 3, in <module>
window = pyglet.window.Window(resizable=True)
File "/Library/Python/2.7/site-packages/pyglet/__init__.py", line 306, in __getattr__
__import__(import_name)
File "/Library/Python/2.7/site-packages/pyglet/window/__init__.py", line 1669, in <module>
from pyglet.window.carbon import CarbonPlatform, CarbonWindow
File "/Library/Python/2.7/site-packages/pyglet/window/carbon/__init__.py", line 69, in <module>
framework='/System/Library/Frameworks/QuickTime.framework')
File "/Library/Python/2.7/site-packages/pyglet/lib.py", line 90, in load_library
return self.load_framework(kwargs['framework'])
File "/Library/Python/2.7/site-packages/pyglet/lib.py", line 226, in load_framework
lib = ctypes.cdll.LoadLibrary(realpath)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ctypes/__init__.py", line 443, in LoadLibrary
return self._dlltype(name)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ctypes/__init__.py", line 365, in __init__
self._handle = _dlopen(self._name, mode)
OSError: dlopen(/System/Library/Frameworks/QuickTime.framework/QuickTime, 6): no suitable image found. Did find:
/System/Library/Frameworks/QuickTime.framework/QuickTime: mach-o, but wrong architecture
/System/Library/Frameworks/QuickTime.framework/QuickTime: mach-o, but wrong architecture

Related

In pydroid3, I have installed pywhatkit5.4 using pip menu. But, import pywhatkit in program fails

Traceback (most recent call last):
File "/data/user/0/ru.iiec.pydroid3/files/accomp_files/iiec_run/iiec_run.py", line 31, in <module>
start(fakepyfile,mainpyfile)
File "/data/user/0/ru.iiec.pydroid3/files/accomp_files/iiec_run/iiec_run.py", line 30, in start
exec(open(mainpyfile).read(), __main__.__dict__)
File "<string>", line 2, in <module>
File "/data/user/0/ru.iiec.pydroid3/files/aarch64-linux-android/lib/python3.9/site-packages/pywhatkit/__init__.py", line 16, in <module>
from pywhatkit.whats import (
File "/data/user/0/ru.iiec.pydroid3/files/aarch64-linux-android/lib/python3.9/site-packages/pywhatkit/whats.py", line 7, in <module>
import pyautogui as pg
File "/data/user/0/ru.iiec.pydroid3/files/aarch64-linux-android/lib/python3.9/site-packages/pyautogui/__init__.py", line 249, in <module>
import mouseinfo
File "/data/user/0/ru.iiec.pydroid3/files/aarch64-linux-android/lib/python3.9/site-packages/mouseinfo/__init__.py", line 223, in <module>
_display = Display(os.environ['DISPLAY'])
File "/data/user/0/ru.iiec.pydroid3/files/aarch64-linux-android/lib/python3.9/os.py", line 679, in __getitem__ raise KeyError(key) from None
KeyError: 'DISPLAY'
[Program finished]
import pywhatkit
pywhatkit.sendwhatmsg ("+9195352xxxx5", "Hello ", 14, 10)
pywhatkit not getting imported in this 2 line program. Above is the error message.

run pyautogui python script from CLI/SSH

I expect I can run pyautogui in SSH
#t.py
import pyautogui
print(pyautogui.size())
It gave me error display;
root#server-kentang:~/py# python3 t.py
Traceback (most recent call last): File "/usr/local/lib/python3.8/dist-packages/Xlib/support/unix_connect.py", line 76, in get_socket
s.connect('/tmp/.X11-unix/X%d' % dno) FileNotFoundError: [Errno 2] No such file or directory
During handling of the above exception, another exception occurred:
Traceback (most recent call last): File "t.py", line 1, in <module>
import pyautogui
File "/usr/local/lib/python3.8/dist-packages/pyautogui/__init__.py", line 249, in <module>
import mouseinfo
File "/usr/local/lib/python3.8/dist-packages/mouseinfo/__init__.py", line 223, in <module>
_display = Display(os.environ['DISPLAY'])
File "/usr/local/lib/python3.8/dist-packages/Xlib/display.py", line 80, in __init__
self.display = _BaseDisplay(display)
File "/usr/local/lib/python3.8/dist-packages/Xlib/display.py", line 62, in __init__
display.Display.__init__(*(self, ) + args, **keys)
File "/usr/local/lib/python3.8/dist-packages/Xlib/protocol/display.py", line 58, in __init__
self.socket = connect.get_socket(name, host, displayno)
File "/usr/local/lib/python3.8/dist-packages/Xlib/support/connect.py", line 76, in get_socket
return mod.get_socket(dname, host, dno)
File "/usr/local/lib/python3.8/dist-packages/Xlib/support/unix_connect.py", line 78, in get_socket
raise error.DisplayConnectionError(dname, str(val))
Xlib.error.DisplayConnectionError: Can't connect to display ":0": [Errno 2] No such file or directory
But I already installed XRDP and its XORG and it works fine. I'm using OpenBox as Windows Manager.

How can I fix this error from importing module pyautogui?

I run the python code from the root. Shows an error when I just imported the module:
ERROR : Traceback (most recent call last):
File "/home/amir/photo.py", line 4, in <module>
import pyautogui as gui
File "/usr/local/lib/python3.9/dist-packages/pyautogui/__init__.py", line 249, in <module>
import mouseinfo
File "/usr/local/lib/python3.9/dist-packages/mouseinfo/__init__.py", line 223, in <module>
_display = Display(os.environ['DISPLAY'])
File "/usr/local/lib/python3.9/dist-packages/Xlib/display.py", line 80, in __init__
self.display = _BaseDisplay(display)
File "/usr/local/lib/python3.9/dist-packages/Xlib/display.py", line 62, in __init__
display.Display.__init__(*(self, ) + args, **keys)
File "/usr/local/lib/python3.9/dist-packages/Xlib/protocol/display.py", line 129, in __init__
raise error.DisplayConnectionError(self.display_name, r.reason)
Xlib.error.DisplayConnectionError: Can't connect to display ":1": b'No protocol specified\n'

when execute "from pyzbar import pyzbar" i got a WindowsError, Hope someone more knowledgeable can help. Thanks a lot

here's my code:
from pyzbar import pyzbar
I get the following error:
Traceback (most recent call last):
File "D:/Users/Administrator/Desktop/qrx-tool/test.py", line 1, in <module>
from pyzbar import pyzbar
File "D:\Python27\lib\site-packages\pyzbar\pyzbar.py", line 7, in <module>
from .wrapper import (
File "D:\Python27\lib\site-packages\pyzbar\wrapper.py", line 143, in <module>
c_uint_p, # minor
File "D:\Python27\lib\site-packages\pyzbar\wrapper.py", line 136, in zbar_function
return prototype((fname, load_libzbar()))
File "D:\Python27\lib\site-packages\pyzbar\wrapper.py", line 115, in load_libzbar
libzbar, dependencies = zbar_library.load()
File "D:\Python27\lib\site-packages\pyzbar\zbar_library.py", line 60, in load
dependencies, libzbar = load_objects(Path(__file__).parent)
File "D:\Python27\lib\site-packages\pyzbar\zbar_library.py", line 54, in load_objects
libzbar = cdll.LoadLibrary(str(directory.joinpath(fname)))
File "D:\Python27\lib\ctypes\__init__.py", line 443, in LoadLibrary
return self._dlltype(name)
File "D:\Python27\lib\ctypes\__init__.py", line 365, in __init__
self._handle = _dlopen(self._name, mode)
WindowsError: [Error 193] %1 不是有效的 Win32

clr and kivy conflict with factory.py import error

When I want to import clr, then My kivy env got crashed.
Traceback (most recent call last):
File "demo.py", line 86, in <module>
demoApp().run()
File "C:\Python27\lib\site-packages\kivy\app.py", line 801, in run
self.load_kv(filename=self.kv_file)
File "C:\Python27\lib\site-packages\kivy\app.py", line 598, in load_kv
root = Builder.load_file(rfilename)
File "C:\Python27\lib\site-packages\kivy\lang\builder.py", line 301, in load_file
return self.load_string(data, **kwargs)
File "C:\Python27\lib\site-packages\kivy\lang\builder.py", line 379, in load_string
widget = Factory.get(parser.root.name)()
File "C:\Python27\lib\site-packages\kivy\factory.py", line 139, in __getattr__
module = __import__(name=item['module'], fromlist='.')
TypeError: __import__() takes at least 1 argument (0 given)
Could anyone help me with this? Thanks.

Categories