raspberry pi 3 安裝python pyautogui
主要安裝步驟
linux 需安裝其他的東西sudo apt-get install python-tk sudo apt-get install python3-dev sudo apt-get install scrot sudo pip3 install python3-xlib
最後安裝
sudo pip3 install pyautogui
新版的應該是已安裝好以下:
python-tk python3-dev scrot
錯誤一
如果直接安裝pyautogui會出現以下的錯誤表示缺少xlib
只要安裝 python3-xlib完,再安裝pyautogui就可以了
錯誤二
如果像我其他都安裝好了,但是pyautogui還是安裝不成功,出現以下錯誤那就把 sudo pip3 install pyautogui 改成 sudo xvfb-run pip3 install pyautogui上網查 xvfb-run 應該是模擬安裝的意思
pi@raspberrypi:~ $ sudo pip3 install pyautogui Downloading/unpacking pyautogui Downloading PyAutoGUI-0.9.36.tar.gz (46kB): 46kB downloaded Running setup.py (path:/tmp/pip-build-0mnn6hrh/pyautogui/setup.py) egg_info for package pyautogui Traceback (most recent call last): File "/usr/local/lib/python3.4/dist-packages/Xlib/xauth.py", line 43, in __init__ raw = open(filename, 'rb').read() FileNotFoundError: [Errno 2] No such file or directory: '/root/.Xauthority' During handling of the above exception, another exception occurred: Traceback (most recent call last): File "", line 17, in File "/tmp/pip-build-0mnn6hrh/pyautogui/setup.py", line 6, in version=__import__('pyautogui').__version__, File "/tmp/pip-build-0mnn6hrh/pyautogui/pyautogui/__init__.py", line 115, in from . import _pyautogui_x11 as platformModule File "/tmp/pip-build-0mnn6hrh/pyautogui/pyautogui/_pyautogui_x11.py", line 160, in _display = Display(os.environ['DISPLAY']) File "/usr/local/lib/python3.4/dist-packages/Xlib/display.py", line 80, in __init__ self.display = _BaseDisplay(display) File "/usr/local/lib/python3.4/dist-packages/Xlib/display.py", line 62, in __init__ display.Display.__init__(*(self, ) + args, **keys) File "/usr/local/lib/python3.4/dist-packages/Xlib/protocol/display.py", line 61, in __init__ name, host, displayno) File "/usr/local/lib/python3.4/dist-packages/Xlib/support/connect.py", line 91, in get_auth return mod.get_auth(sock, dname, host, dno) File "/usr/local/lib/python3.4/dist-packages/Xlib/support/unix_connect.py", line 103, in new_get_auth au = xauth.Xauthority() File "/usr/local/lib/python3.4/dist-packages/Xlib/xauth.py", line 45, in __init__ raise error.XauthError('~/.Xauthority: %s' % err) Xlib.error.XauthError: ~/.Xauthority: [Errno 2] No such file or directory: '/root/.Xauthority' Complete output from command python setup.py egg_info: Traceback (most recent call last): File "/usr/local/lib/python3.4/dist-packages/Xlib/xauth.py", line 43, in __init__ raw = open(filename, 'rb').read() FileNotFoundError: [Errno 2] No such file or directory: '/root/.Xauthority' During handling of the above exception, another exception occurred: Traceback (most recent call last): File " ", line 17, in File "/tmp/pip-build-0mnn6hrh/pyautogui/setup.py", line 6, in version=__import__('pyautogui').__version__, File "/tmp/pip-build-0mnn6hrh/pyautogui/pyautogui/__init__.py", line 115, in from . import _pyautogui_x11 as platformModule File "/tmp/pip-build-0mnn6hrh/pyautogui/pyautogui/_pyautogui_x11.py", line 160, in _display = Display(os.environ['DISPLAY']) File "/usr/local/lib/python3.4/dist-packages/Xlib/display.py", line 80, in __init__ self.display = _BaseDisplay(display) File "/usr/local/lib/python3.4/dist-packages/Xlib/display.py", line 62, in __init__ display.Display.__init__(*(self, ) + args, **keys) File "/usr/local/lib/python3.4/dist-packages/Xlib/protocol/display.py", line 61, in __init__ name, host, displayno) File "/usr/local/lib/python3.4/dist-packages/Xlib/support/connect.py", line 91, in get_auth return mod.get_auth(sock, dname, host, dno) File "/usr/local/lib/python3.4/dist-packages/Xlib/support/unix_connect.py", line 103, in new_get_auth au = xauth.Xauthority() File "/usr/local/lib/python3.4/dist-packages/Xlib/xauth.py", line 45, in __init__ raise error.XauthError('~/.Xauthority: %s' % err) Xlib.error.XauthError: ~/.Xauthority: [Errno 2] No such file or directory: '/root/.Xauthority' ---------------------------------------- Cleaning up... Command python setup.py egg_info failed with error code 1 in /tmp/pip-build-0mnn6hrh/pyautogui Storing debug log for failure in /root/.pip/pip.log
成功訊息
pi@raspberrypi:~ $ sudo xvfb-run pip3 install pyautogui Downloading/unpacking pyautogui Downloading PyAutoGUI-0.9.36.tar.gz (46kB): 46kB downloaded Running setup.py (path:/tmp/pip-build-shfbked2/pyautogui/setup.py) egg_info for package pyautogui Downloading/unpacking pymsgbox (from pyautogui) Downloading PyMsgBox-1.0.6.zip Running setup.py (path:/tmp/pip-build-shfbked2/pymsgbox/setup.py) egg_info for package pymsgbox Downloading/unpacking PyTweening>=1.0.1 (from pyautogui) Downloading PyTweening-1.0.3.zip Running setup.py (path:/tmp/pip-build-shfbked2/PyTweening/setup.py) egg_info for package PyTweening Requirement already satisfied (use --upgrade to upgrade): Pillow in /usr/lib/python3/dist-packages (from pyautogui) Downloading/unpacking pyscreeze (from pyautogui) Downloading PyScreeze-0.1.13.tar.gz Running setup.py (path:/tmp/pip-build-shfbked2/pyscreeze/setup.py) egg_info for package pyscreeze Installing collected packages: pyautogui, pymsgbox, PyTweening, pyscreeze Running setup.py install for pyautogui Running setup.py install for pymsgbox Running setup.py install for PyTweening Running setup.py install for pyscreeze Successfully installed pyautogui pymsgbox PyTweening pyscreeze Cleaning up...
留言
張貼留言