我一直在Ubuntu上尝试使用Pyautogui,但我就是不能让它工作,而我在Windows上做起来却没有问题。不管我安装了什么依赖项,每次我尝试使用Pyautogui时,它都会返回:
NOTE: You must install Tkinter on Linux to use MouseInfo. Run the following: sudo apt-get install python3-tk python3-dev
如果我尝试:sudo apt-get install python3-tk python3-dev
python3-dev is already the newest version (3.8.2-0ubuntu2).
python3-tk is already the newest version (3.8.5-1~20.04.1).
0 upgraded, 0 newly installed, 0 to remove, and 0 not upgraded.
如果我尝试:pip3 install pyautogui
Requirement already satisfied: pyautogui in /home/lucas/.virtualenvs/recursos/lib/python3.8/site-packages (0.9.52)
Requirement already satisfied: pymsgbox in /home/lucas/.virtualenvs/recursos/lib/python3.8/site-packages (from pyautogui) (1.0.9)
Requirement already satisfied: PyTweening>=1.0.1 in /home/lucas/.virtualenvs/recursos/lib/python3.8/site-packages (from pyautogui) (1.0.3)
Requirement already satisfied: pyscreeze>=0.1.21 in /home/lucas/.virtualenvs/recursos/lib/python3.8/site-packages (from pyautogui) (0.1.26)
Requirement already satisfied: pygetwindow>=0.0.5 in /home/lucas/.virtualenvs/recursos/lib/python3.8/site-packages (from pyautogui) (0.0.9)
Requirement already satisfied: mouseinfo in /home/lucas/.virtualenvs/recursos/lib/python3.8/site-packages (from pyautogui) (0.1.3)
Requirement already satisfied: python3-Xlib in /home/lucas/.virtualenvs/recursos/lib/python3.8/site-packages (from pyautogui) (0.15)
Requirement already satisfied: pyrect in /home/lucas/.virtualenvs/recursos/lib/python3.8/site-packages (from pygetwindow>=0.0.5->pyautogui) (0.1.4)
Requirement already satisfied: Pillow>=6.2.1 in /home/lucas/.virtualenvs/recursos/lib/python3.8/site-packages (from pyscreeze>=0.1.21->pyautogui) (8.0.1)
Requirement already satisfied: pyperclip in /home/lucas/.virtualenvs/recursos/lib/python3.8/site-packages (from mouseinfo->pyautogui) (1.8.1)
pip freeze > requirements.txt
(我试图用Pyautogui运行一个python文件的virtualenv的)
altgraph==0.17
asgiref==3.3.1
beautifulsoup4==4.9.3
Django==3.1.3
django-bootstrap4==2.3.1
evdev==1.3.0
MouseInfo==0.1.3
mypy==0.790
mypy-extensions==0.4.3
passlib==1.7.4
Pillow==8.0.1
playsound==1.2.2
PyAutoGUI==0.9.52
PyGetWindow==0.0.9
pyinstaller==4.1
pyinstaller-hooks-contrib==2020.10
PyMsgBox==1.0.9
pynput==1.7.1
pyperclip==1.8.1
PyRect==0.1.4
PyScreeze==0.1.26
python-xlib==0.29
python3-xlib==0.15
pytube==10.0.0
PyTweening==1.0.3
pytz==2020.4
six==1.15.0
soupsieve==2.0.1
sqlparse==0.4.1
typed-ast==1.4.1
typing-extensions==3.7.4.3
是否还有其他需要安装的依赖项?我不知道还能做什么。
2条答案
按热度按时间njthzxwz1#
该软件包有点奇怪。这可能会解决您的问题:
cbeh67ev2#
注意:您必须在Linux上安装Tkinter才能使用MouseInfo。请执行下列程式:python3-tk python3-dev的安装程序
我也遇到过这个问题,即使使用
sudo apt-get install python3-tk python3-dev
也不起作用。首先尝试运行此命令,指定python版本,例如,在python 3.10中:
基本上我通过这样做解决了我的问题:
重新编译并重新安装python3.10,指定包含tcl、tk include和库的文件夹路径
重新安装Python 3.10
编辑配置
搜索with-tcltk-includes/with-tcltk-libs并替换“..."中的部分,如下所示:
然后运行
注意:将命令“make -j2”上的2替换为处理器内核数