1

the code is:

import pyautogui
pyautogui.moveTo(502, 632)
input()

it works in IDLE but when i save and run it, the screen flashes and closes. I tried reading it and it said error in line 1. Please Help.

  • Try to get more information about the error message. Your top priority is to be able to view it without the window closing. The console tends to vanish abruptly at the end of the program if you initially started the program by double-clicking its icon in a file explorer. Instead, open a command line and execute your program by name. – Kevin Mar 14 '19 at 12:19
  • Related reading: [How to keep a Python script output window open?](https://stackoverflow.com/q/1000900/953482) – Kevin Mar 14 '19 at 12:26
  • The error message is: Traceback(most recent call last): File "C:\Users\xxxx\Desktop\dsff.py", line 1, in (modules) import pyautogui ModuleNotFoundError: No module named 'pyautogui' – OneChannelEverything Mar 15 '19 at 07:55
  • ModuleNotFoundErrors usually occur when the module is not installed. It's unusual that the error still appears even if you execute `pip install`. Assuming the install completes with no errors, the next most likely explanation is that you have multiple versions of Python installed, and `pip` is installing to one and not the other. Try to determine whether `pip` and `python` are in the same directory. On Windows, you might try `where pip` and `where python` on the command line. – Kevin Mar 15 '19 at 12:33
  • I guess they are in the same folder. only after Python35-32 there is python.exe and in pip its scripts/pip.exe – OneChannelEverything Mar 15 '19 at 19:28
  • If you're saying "python's path is Python35-32/python.exe and pip's path is Python35-32/scripts/pip.exe", then I would expect `pip install` to succesfully work. If you're saying "python's path is Python35/python.exe and pip's path is Python32/scripts/pip.exe" then you definitely have more than one Python installed. – Kevin Mar 15 '19 at 19:32
  • pip install successfully worked, like you said in the first situation. – OneChannelEverything Mar 16 '19 at 15:54
  • Please Help me, I cant fix it. – OneChannelEverything Mar 29 '19 at 06:48

3 Answers3

0

Please check

  1. Your python versions in both places you are running,
  2. Whether pyautogui is installed in the env where you are running as .py file

It is running fine in place as .py file

Rupesh Goud
  • 131
  • 1
  • 9
0

I guess your interpreter doesn't have pyautogui.

just before run try this: pip install pyautogui this required install once.

Sima
  • 122
  • 4
  • Please Help me, I cant fix it. – OneChannelEverything Mar 29 '19 at 06:49
  • @OneChannelEverything what you mean "it didnt work", please give more information. `- First step run "cmd"` `- Second step change directory to your script directory "cd "` `- Third step run your script "python "` And write here output from there. – Sima Mar 29 '19 at 09:15
0

I found the solution, the thing is i had Anaconda distribution of python installed. Idle was installed in normal python while the when i executed it as .py, anaconda was running it. I just uninstalled anaconda.