Um Cara Qualquer
Um Cara Qualquer

Reputation: 61

I run a .py script in my cmd and the error "ModuleNotFoundError" appears

I created a script in python that needs the "pyautogui" so that it works the way I want. but when I open in cmd I get the error "ModuleNotFoundError: No Module Named 'PyAutoGui". I've search how to fix it, but they do not fix it or it's too complicated. How do I run my .py in cmd using "pyautogui" without having to open pycharm every time to use it? i use python 3.7.2 64 bits (updated)

Error: http://prntscr.com/metcvt

Already tried to install python in another directory and another version.

import pyautogui

print("#####--##### ADVERTENCIAS #####-#####")

print("\nMantenha sempre seu mouse acima do objeto!")

print("Não coloque numeros exagerados.")

print("Nem todos os clicks podem ser executados, mas nunca sera mais que o 
solicitado.")

print("Para sua segurança inicie o programa com a janela ao lado do objeto")

def setup():

    clicks=int(input("\nQuantos clicks você deseja? "))

    pyautogui.click(clicks=clicks,interval=0.01)

    setup()

setup()

I expected that I could give an input and run my code, but what I get is just a error.

Upvotes: 1

Views: 4643

Answers (3)

Naman Chikara
Naman Chikara

Reputation: 174

If you’re using Python 2.7.9 (or greater) or Python 3.4 (or greater), then PIP comes installed with Python by default. If you still aren't able to use pip do the following:

For windows: Right click on the below given link and select Save As... and save it to Downloads (not a compulsion) now open that folder and right-click in free space while holding shift, then select 'open PowerShell here' or 'open Command-prompt here', run inpython get-pip.py

get-pip.py installer script or if you're using python 3.2 use: get-pip for python 3.2

after that pip will install in your system now run pip install pyautogui or pip3 install pyautogui

Upvotes: 1

JLynchDesigns
JLynchDesigns

Reputation: 157

From what I can see here, I'm thinking that PyAutoGUI is not in a directory where it can be accessed via CMD. I'm also assuming that the PyAutoGUI package is included in your PyCharm project?

First, see if the package is in your system path with:

>>> import sys
>>> sys.path
#output

If it's not in one of those directories, it cannot be accessed with CMD. You can either put it in one of the listed directories, or add it to the sys.path, use this command:

>>> sys.path.append(r"[package directory]\\PyAutoGUI")

Now if you try running your script in CMD, it will work.

If you haven't actually installed PyAutoGUI yet, just run:

pip install pyautogui

Upvotes: 2

Dan S Musetoiu
Dan S Musetoiu

Reputation: 64

in your cmd: pip install pyautogui or pip3 install pyautogui

should work

Upvotes: 0

Related Questions