Open executionByFork opened 6 years ago
$ pip freeze
numpy==1.15.4
opencv-python==3.4.3.18
Pillow==5.3.0
PyAutoGUI==0.9.38
PyMsgBox==1.0.6
PyScreeze==0.1.18
PyTweening==1.0.3
six==1.11.0
xlib==0.21
Additionally, please see my other issue I opened. They might be related #279
I have the same problems with locateonscreen which os u use?
Also, I have just found that pyautogui.screenshot()
returns a black image. This may be the core of the problem.
>>> im = pyautogui.screenshot()
>>> pix = im.load()
>>> for x in range(1300):
... for y in range(700):
... if pix[x,y] != (0,0,0):
... print(pix[x,y])
...
>>>
Still having this problem... I tried using pyautogui on my other laptop running PureOS. Nothing is different. The screenshots this module takes are just black screens.
$ python3
Python 3.6.7 (default, Oct 21 2018, 08:08:16)
[GCC 8.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import pyautogui
>>> im1 = pyautogui.screenshot()
>>> im1.save('test.png')
>>>
The screenshot:
$ pip freeze
Pillow==5.3.0
PyAutoGUI==0.9.38
PyMsgBox==1.0.6
PyScreeze==0.1.18
PyTweening==1.0.3
six==1.11.0
xlib==0.21
I'm not understanding how I am having the exact same issue on two separate laptops running separate operating systems, while no one else has reported issues like this. What am I doing wrong? I installed the module via pip
inside of a virtual environment. I haven't seen anything in the documentation that says I need to do anything else
I think the problem is that pyautogui doesn't come to terms with wayland yet, the x11 substitute.
I have the same issue. Have you been able to solve the balck screen problem ?
I have a very similar problem - pyautogui.pixel gives me garbage values, for ex. (43, 45, 23) when the pixel is clearly white, or (34, 200, 10) when it's more blue than anything. I've tried the script on other people's macs, and I get the same garbage values (and no errors). Anyone know if this could possibly be a problem with pyautogui?
It seems that after you install the pyautogui and its following packages, you should restart the computer. At first my pyautogui on my ubuntu doesn't read pixel nor interact with mouse. But after restarting, now it works like a charm
I have a very similar problem - pyautogui.pixel gives me garbage values, for ex. (43, 45, 23) when the pixel is clearly white, or (34, 200, 10) when it's more blue than anything. I've tried the script on other people's macs, and I get the same garbage values (and no errors). Anyone know if this could possibly be a problem with pyautogui?
I had the same problem, I think that the restart chauanphu talked about solved the problem.
When I tried to run the function pyautogui.displayMousePosition()
as root, it reported this error:
error.DisplayConnectionError(self.display_name, r.reason)
Xlib.error.DisplayConnectionError: Can't connect to display ":0": b'Authorization required, but no authorization protocol specified
sudo nano /etc/gdm3/custom.conf
#WaylandEnable=false
to force your computer to use x11Hope this would be helpful !
When I tried to run the function
pyautogui.displayMousePosition()
as root, it reported this error:error.DisplayConnectionError(self.display_name, r.reason) Xlib.error.DisplayConnectionError: Can't connect to display ":0": b'Authorization required, but no authorization protocol specified
- A website explains that the trouble is cause because pyautogui has problem with wayland. So after searching on website, I found this useful link https://askubuntu.com/questions/961304/how-do-you-switch-from-wayland-back-to-xorg-in-ubuntu-17-10
- Just switch the display protocol from wayland back to x11:
sudo nano /etc/gdm3/custom.conf
- Remove # in
#WaylandEnable=false
to force your computer to use x11- Restart the computer
Hope this would be helpful !
There's no pyautogui function displayMousePosition()
that I know of - only .position()
(Reference: https://pyautogui.readthedocs.io/en/latest/mouse.html)
That's even besides the point. Pyautogui is so slow at basically everything so if you can use another library for any tasks, do it. I would do this instead:
from pynput.mouse import Button, Controller
mouse = Controller()
(x, y) = mouse.position
When I tried to run the function
pyautogui.displayMousePosition()
as root, it reported this error:error.DisplayConnectionError(self.display_name, r.reason) Xlib.error.DisplayConnectionError: Can't connect to display ":0": b'Authorization required, but no authorization protocol specified
- A website explains that the trouble is cause because pyautogui has problem with wayland. So after searching on website, I found this useful link https://askubuntu.com/questions/961304/how-do-you-switch-from-wayland-back-to-xorg-in-ubuntu-17-10
- Just switch the display protocol from wayland back to x11:
sudo nano /etc/gdm3/custom.conf
- Remove # in
#WaylandEnable=false
to force your computer to use x11- Restart the computer
Hope this would be helpful !
Mahn....This is the solution for me! When I did this, while restarting, my laptop froze, but I managed to get back into linux and is working fine.
When I tried to run the function
pyautogui.displayMousePosition()
as root, it reported this error:error.DisplayConnectionError(self.display_name, r.reason) Xlib.error.DisplayConnectionError: Can't connect to display ":0": b'Authorization required, but no authorization protocol specified
* A website explains that the trouble is cause because pyautogui has problem with wayland. So after searching on website, I found this useful link [https://askubuntu.com/questions/961304/how-do-you-switch-from-wayland-back-to-xorg-in-ubuntu-17-10](url) * Just switch the display protocol from wayland back to x11: 1. `sudo nano /etc/gdm3/custom.conf` 2. Remove # in `#WaylandEnable=false` to force your computer to use x11 3. Restart the computer
Hope this would be helpful !
That did the trick! Thanks.
https://www.phoronix.com/news/Wayland-Protocols-1.37
"The other two new protocols are ext-image-capture-source and ext-image-copy-capture that allow for capturing the pixel content of outputs and top-level windows. "
I am having an odd issue where
pyautogui
isn't properly reading the pixels on my screen. I believe this is what is causing thelocateOnScreen()
function to not work at all for me. Basically, every call topyautogui.pixel(x, y)
returns(0,0,0)
for anyx
andy
.In the above, I got the location of my mouse which was hovering over a blue icon, and tried to read the RGB values of the pixel. I've tried several different colors and locations on my screen, all return the same
(0,0,0)
output. I have tried using theregion
parameter,grayscale
, and evenconfidence
(which usesopencv-python
) to getlocateOnScreen()
to work without any luck.Originally, I was curious if it there was something wrong with the hardware of my laptop. I am running Ubuntu on a machine that was originally a Windows install. So I tried the following with
PIL
The
PIL
library works as it's supposed to, so it's not some sort of odd hardware issue. There is something wrong with thepyautogui
library, which is quite frustrating because I need the library's image recognition to work for my script. Any suggestions on how to fix this?I am running Ubuntu 18.04 LTS, and it is essentially a fresh install.