Reputation: 43
import pyautogui
print("hello")
After running this I am presented with the following:
C:\Users\Darkm\Anaconda3\envs\PythonChallenges\python.exe C:/Users/Darkm/PycharmProjects/PythonChallenges/Automation1.py
Traceback (most recent call last):
File "C:/Users/Darkm/PycharmProjects/PythonChallenges/Automation1.py", line 1, in <module>
import pyautogui
ModuleNotFoundError: No module named 'pyautogui'
Process finished with exit code 1
Could somebody help me understand why I cannot import pyautogui?
Some background information:
1.) I only have one version of python (3.7.4)
2.) I have already installed the module through "pip install pyautogui" in cmd prompt.
3.) Pyautogui is installed under C:\Users\Darkm\Anaconda3\Lib\site-packages
4.) Pyautogui does not show up when I go into file > settings > project interpreter and try to add it manually (it just doesn't show up).
5.) Have restarted computer multiple times
At this point I cannot figure out why I'm unable to import pyautogui, any help would be greatly appreciated!
Upvotes: 4
Views: 25385
Reputation: 11
For the people here having this problem and actually are using VS Code, you should try installing it within a virtual environment.
I personally would recommend Python UV. Just follow the steps:
Now you should be good to go.
Upvotes: 0
Reputation: 29
make sure that library is installed in same version of python
Upvotes: 0
Reputation: 121
You are using Pycharm IDE. To install packages in Pycharm, you can use the project interpreter in settings or type the following in the terminal:
pip install pyautogui
Upvotes: 0
Reputation:
Go to terminal. type "pip install pyautogui"
pip install pyautogui
Your problem should be solved now. If it isn't try this.
!pip install pyautogui
Upvotes: 0
Reputation: 1
Try this...
# Install a pip package in the current Jupyter kernel
import sys
!{sys.executable} -m pip install numpy
Tutorial from Pythonic Perambulations
Upvotes: 0
Reputation: 3
Make sure you have the latest version of python installed on your computer
On Windows:
Open up Windows PowerShell. Type py -m pip install pyautogui
and wait for 2 minutes. Then, restart your IDE. Try running your code, it should work now.
On a Mac:
Open up iTerm. Type pip3 install pyautogui
or py -m pip3 install pyautogui
, and wait for 2 minutes. Then, restart your IDE. Then just simply try to run your code, it should be working.
Hope this helped!
Upvotes: 0
Reputation: 63
You and also do this trick on imports
import subprocess
try:
import pyautogui
except ImportError:
subprocess.call("pip install pyautogui")`
Upvotes: 1
Reputation: 49
If you face module not found on Jupyter environment you had to install it on Jupyter environment instead of installing it on command prompt
by this command (for windows)
!pip install pyautogui
After that you can easily import and use it.
Whenever you want to tell Jupyter that this is system command you should put !
before your command.
Upvotes: 0
Reputation: 145
It's probably because of pycharm.
If it's not pycharm and you still have problems you can try:
Cmd:
python -m pip install < module >
To append to PYTHONPATH:
IDE:
import sys
sys.path.append('< path >')
Upvotes: 0
Reputation: 1064
Why are you getting this error?
Because you are using PyCharm.
In PyCharm you don't need to install python packages from command prompt, in PyCharm you need to install python packages from PyCharm Project Interpreter.
Here are some tips that can help you!
Step 1: Go to PyCharm settings and go to this directory: Preferences and select Interpreter Settings
Screenshot:
Step 2: Click on this plus icon.
Screenshot:
Step 3: Type your package name and select package.
Screenshot:
Step4: Then click on install button.
Step 5: Click on okay
Then wait for two to three minutes and try again.
Hopefully it'll work.
Upvotes: 6