asweigart / pyautogui

A cross-platform GUI automation Python module for human beings. Used to programmatically control the mouse & keyboard.
BSD 3-Clause "New" or "Revised" License
10.45k stars 1.26k forks source link

PyAutoGUI not installing due to error while installing Pillow #811

Open GitHOb1 opened 1 year ago

GitHOb1 commented 1 year ago

Screenshot (9) Screenshot (10) Screenshot (11) Screenshot (12)

I'm tring to install the latest version of pyautogui using pip, in the proccess of installing Pillow I keep on getting the error: "Could not build wheels for Pillow, which is required to install pyproject.toml-based projects". I tried various ways I found to fix it including installing an older version of Pillow that does install well, none of them help.

I'm using Windows 10, Python 3.8. I've added screenshots of the installation and of the packages I have installed.

Would appreciate help, thanks

rpj09 commented 1 year ago

Try out these steps

  1. Install the necessary dependencies for Pillow by running the following commands:

    apt-get install libjpeg-dev zlib1g-dev
  2. Next, install Pillow using pip3:

    pip3 install Pillow
  3. To ensure you have the latest version of setuptools and wheel, update it:

    sudo pip install -U setuptools wheel
minhngoc25a commented 1 year ago

Incorrect instructions. OP is using Windows, not Linux.

  1. Use the command cd in Command Prompt to change the directory to the directory of your source code. Then create a virtual environment if you haven't:
    py -m pip install virtualenv
    py -m venv .venv
  2. Then activate it:
    .\.venv\Scripts\activate.bat
  3. Now that you've activated a virtual environment, you don't have to worry about other packages conflicting with the global packages because the virtual environment doesn't use the globally-installed packages but packages installed in the .venv folder instead. Install pyautogui as normal:
    pip install pyautogui

    Note that if you're using PyCharm to run Python files, you'll have to change the default Python interpreter for your Python project into the one inside the virtual environment for it to work.