iStillHaveToGoPee
iStillHaveToGoPee

Reputation: 45

cmd is searching the wrong file path when trying to use pip to install new module in python

I am using the CMD to install the pyautogui module and keep getting the following error:

Command "python setup.py egg_info" failed with error code 1 in C:\Users\ANDBOD~1\AppData\Local\Temp\pip-build-pmc8kstd\pyscreeze\

I use pip install pyautogui to start the install, and cmd displays the following code before the error appears:

    C:\WINDOWS\system32>pip install pyautogui
Collecting pyautogui
  Using cached PyAutoGUI-0.9.33.zip
Collecting pymsgbox (from pyautogui)
  Using cached PyMsgBox-1.0.3.zip
Collecting PyTweening>=1.0.1 (from pyautogui)
  Using cached PyTweening-1.0.3.zip
Collecting Pillow (from pyautogui)
  Downloading Pillow-4.0.0-cp36-cp36m-win32.whl (1.3MB)
    100% |████████████████████████████████| 1.3MB 78kB/s
Collecting pyscreeze (from pyautogui)
  Using cached PyScreeze-0.1.8.zip
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "C:\Users\ANDBOD~1\AppData\Local\Temp\pip-build-pmc8kstd\pyscreeze\setup.py", line 6, in <module>
        version=__import__('pyscreeze').__version__,
      File "C:\Users\ANBDOD~1\AppData\Local\Temp\pip-build-pmc8kstd\pyscreeze\pyscreeze\__init__.py", line 21, in <module>
        from PIL import Image
    ModuleNotFoundError: No module named 'PIL'

I believe the error is happening because cmd is searching the C:\Users\ANDBOD... file path and that is not where I have my python files saved. I've tried opening cmd as admin but received the same error.

I used the exact same process to install openpyxl 2 weeks ago and had no issue, but now I get the same issue no matter which module I try to install.

Thanks in advance for the help!

Upvotes: 1

Views: 533

Answers (2)

iStillHaveToGoPee
iStillHaveToGoPee

Reputation: 45

The following comments from above are how I solved this issue:

@Lafada - ImportError: No module named PIL

@MattDMo - The directory shown is just a temp directory, don't worry about it. If you read down through the output, it will tell you exactly what is wrong. pip is trying to install pyautogui, which has a number of dependencies. One of those dependencies, pyscreeze, needs the PIL module, which is provided by the Pillow package (yeah, it's confusing). You'll see that Pillow has already been downloaded, but not installed yet, so when the setup.py from PyScreeze tries to import pyscreeze, it fails because it can't yet find the PIL module. Solution? pip install pillow, then install pyautogui.

Upvotes: 1

sriram lamsal
sriram lamsal

Reputation: 17

when there is no module PIL only then this error will occur, its simle. Install PIL while you could also check some other threads.

ImportError: No module named PIL

Upvotes: 0

Related Questions