pythonの環境構築の際に起きるトラブルの解決策です。
LinuxMint18.3にてpyautoguiを使うためにインストールしましたが、うまく行きませんでした。散々調べてインストールできるようになりましたので、その解決法歩を説明します。
公式サイトの手順
1 2 3 4 5 |
$pip3 install python3-xlib $sudo apt-get install scrot $sudo apt-get install python3-tk $sudo apt-get install python3-dev $pip3 install pyautogui |
1行目の pip3 install python3-xlib でいきなりエラー
1 2 3 4 5 6 7 8 9 10 11 12 |
Collecting python3-xlib Downloading https://files.pythonhosted.org/packages/ef/c6/2c5999de3bb1533521f1101e8fe56fd9c266732f4d48011c7c69b29d12ae/python3-xlib-0.15.tar.gz (132kB) 100% |????????????????????????????????| 133kB 2.3MB/s Complete output from command python setup.py egg_info: Traceback (most recent call last): File "<string>", line 1, in <module> ImportError: No module named 'setuptools' ---------------------------------------- Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-kcnp05ms/python3-xlib/ You are using pip version 8.1.1, however version 18.0 is available. You should consider upgrading via the 'pip install --upgrade pip' command. |
setuptoolsがないことが原因らしい。これをインストール。
1 |
$ sudo pip3 install --upgrade setuptools |
再度 python3-xlibのインストール
1 2 3 4 5 6 7 8 9 |
$ sudo pip3 install python3-xlib The directory '/home/xxxxxxxx/.cache/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag. The directory '/home/xxxxxxxx/.cache/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag. Collecting python3-xlib Downloading https://files.pythonhosted.org/packages/ef/c6/2c5999de3bb1533521f1101e8fe56fd9c266732f4d48011c7c69b29d12ae/python3-xlib-0.15.tar.gz (132kB) 100% |????????????????????????????????| 133kB 3.2MB/s Installing collected packages: python3-xlib Running setup.py install for python3-xlib ... done Successfully installed python3-xlib-0.15 |
無事インストールできた。それ以降のコマンドも成功。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
$ sudo pip3 install pyautogui The directory '/home/xxxxxxxx/.cache/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag. The directory '/home/xxxxxxx/.cache/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag. Collecting pyautogui Downloading https://files.pythonhosted.org/packages/69/81/a8f44c4b613717c25e0cdabf405e942fc7c7bcedf3198c58c79fdbababc0/PyAutoGUI-0.9.38.tar.gz (47kB) 100% |????????????????????????????????| 51kB 1.9MB/s Collecting pymsgbox (from pyautogui) Downloading https://files.pythonhosted.org/packages/b6/65/86379ede1db26c40e7972d7a41c69cdf12cc6a0f143749aabf67ab8a41a1/PyMsgBox-1.0.6.zip Collecting PyTweening>=1.0.1 (from pyautogui) Downloading https://files.pythonhosted.org/packages/b9/f8/c32a58d6e4dff8aa5c27e907194d69f3b57e525c2e4af96f39c6e9c854d2/PyTweening-1.0.3.zip Requirement already satisfied: Pillow in /usr/lib/python3/dist-packages (from pyautogui) (3.1.2) Collecting pyscreeze (from pyautogui) Downloading https://files.pythonhosted.org/packages/1c/80/ba95b654c92264675a8e67646d0f80066e0285c2a3ccd466126035c3fbbf/PyScreeze-0.1.18.tar.gz Installing collected packages: pymsgbox, PyTweening, pyscreeze, pyautogui Running setup.py install for pymsgbox ... done Running setup.py install for PyTweening ... done Running setup.py install for pyscreeze ... done Running setup.py install for pyautogui ... done Successfully installed PyTweening-1.0.3 pyautogui-0.9.38 pymsgbox-1.0.6 pyscreeze-0.1.18 |
pythonは環境構築で躓くことが多くて困るのですが、何とかならないですかね。