Python Forum
Can't import pyautogui - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: Web Scraping & Web Development (https://python-forum.io/forum-13.html)
+--- Thread: Can't import pyautogui (/thread-15064.html)



Can't import pyautogui - HowardHarkness - Jan-02-2019

import time
import random
import pyautogui # This causes import error!
from selenium import webdriver
This has got to be some rookie error, but when I try to import pyautogui, I get the following:
import pyautogui
Traceback (most recent call last):
File "<input>", line 1, in <module>
File "C:\Program Files\JetBrains\PyCharm Community Edition 2018.3.1\helpers\pydev\_pydev_bundle\pydev_import_hook.py", line 21, in do_import
module = self._system_import(name, *args, **kwargs)
ModuleNotFoundError: No module named 'pyautogui'

I get the same problem with pywinauto.

I am running Windoze 10
sys.version_info
sys.version_info(major=3, minor=7, micro=1, releaselevel='final', serial=0)
IDE is pycharm

pyautogui is already installed, according to this:
C:\>pip3 install pyautogui
Requirement already satisfied: pyautogui in c:\users\howard\appdata\local\programs\python\python37-32\lib\site-packages (0.9.39)
Requirement already satisfied: pymsgbox in c:\users\howard\appdata\local\programs\python\python37-32\lib\site-packages (from pyautogui) (1.0.6)
Requirement already satisfied: PyTweening>=1.0.1 in c:\users\howard\appdata\local\programs\python\python37-32\lib\site-packages (from pyautogui) (1.0.3)
Requirement already satisfied: Pillow in c:\users\howard\appdata\local\programs\python\python37-32\lib\site-packages (from pyautogui) (5.4.0)
Requirement already satisfied: pyscreeze in c:\users\howard\appdata\local\programs\python\python37-32\lib\site-packages (from pyautogui) (0.1.18)

Python in in my path. I don't have any problem with importing time, sys, or other modules.

Please tell me what I am doing wrong...


RE: Can't import pyautogui - Larz60+ - Jan-02-2019

you need to install the package, from command line:
pip install pyautogui



RE: Can't import pyautogui - HowardHarkness - Jan-02-2019

Per the original post, I already did that.

I tried both pip and pip3, I'm assuming they both do the same thing. This is from the command line:
C:\>pip install pyautogui
Requirement already satisfied: pyautogui in c:\users\howard\appdata\local\programs\python\python37-32\lib\site-packages (0.9.39)
Requirement already satisfied: pymsgbox in c:\users\howard\appdata\local\programs\python\python37-32\lib\site-packages (from pyautogui) (1.0.6)
Requirement already satisfied: PyTweening>=1.0.1 in c:\users\howard\appdata\local\programs\python\python37-32\lib\site-packages (from pyautogui) (1.0.3)
Requirement already satisfied: Pillow in c:\users\howard\appdata\local\programs\python\python37-32\lib\site-packages (from pyautogui) (5.4.0)
Requirement already satisfied: pyscreeze in c:\users\howard\appdata\local\programs\python\python37-32\lib\site-packages (from pyautogui) (0.1.18)



RE: Can't import pyautogui - hbknjr - Jan-02-2019

(Jan-02-2019, 02:12 AM)HowardHarkness Wrote: IDE is pycharm

You might have multiple Python installations.

The one in your path seems to be
Quote:c:\users\howard\appdata\local\programs\python\python37-32

Also, make sure you are using the same interpreter in PyCharm:
Quote:settings (ctrl+alt+s) -> Project -> Project Interpreter



RE: Can't import pyautogui - snippsat - Jan-02-2019

As mention bye @hbknjr check interpreter in PyCharm

Here some basic test from command line.
C:\
λ python -c "import sys; print(sys.executable)"
C:\python37\python.exe

C:\
λ pip -V
pip 18.1 from c:\python37\lib\site-packages\pip (python 3.7)

C:\
λ python
Python 3.7.0 (v3.7.0:1bf9cc5093, Jun 27 2018, 04:06:47) [MSC v.1914 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import pyautogui
>>>
>>> pyautogui.__version__
'0.9.39'
>>> exit()
Now can test in PyCharm with:
import sys
import pyautogui

print(sys.executable)
print('hello world')
print(pyautogui.__version__)
Output:
C:\Python37\python.exe hello world 0.9.39
As you see same Python interpreter(C:\Python37\python.exe) in command line and in script is used,then it will work.


RE: Can't import pyautogui - HowardHarkness - Jan-04-2019

Thank you!

There were indeed two different pythons installed -- even though both were the same version. Took me a while to figure out how to change the setting in PyCharm, but once I did, the import statements worked.