I have read import error for pyautogui
and this did not answer my question.
I am trying to import pyautogui via the 3.5.2 shell or windows cmd. but when using the shell for:
import pyautogui
Traceback (most recent call last):
File "<pyshell#2>", line 1, in <module>
import pyautogui
ImportError: No module named 'pyautogui'
I have seen people say they resolved by using 3.5 but not for me. I have also seen people say that uninstalling and reinstalling can fix issues. I did this and on reinstall made sure that the path option was selected.
Step one: open windows cmd
Step two: and type in py -3.8 -m pip install pyautogui
You will most likely get a message that says: pip is not up to date, it would look like this: https://i.stack.imgur.com/DOfzQ.png
if you get this error Type in: py -m pip install --upgrade pip
Step three: Open: https://bootstrap.pypa.io/get-pip.py and copy everything on this page
Step four: Open IDLE and run what you just copied
Step five: Open windows cmd again and try py -3.8 -m pip install pyautogui again
Step six: Now try to run it again.
if this doesnt work please show us the errors you get.
Check that you are installing the package using the correct Python Version, in the documentation says that you have to install correspondant to your python version. In my case, I fixed it using python 3.9 (and making sure that my intepreter in VSC is set to Python 3.9.1)
Try doing pip install pyautogui and if it says all requirements are satisfied type in pip show pyautogui and if it shows then just try restarting your IDE and it should work
Related
I have this problem when I try to run an app that imports turtle:
Traceback (most recent call last):
File "/home/panos/Documents/python/challenge_60.py", line 1, in <module>
import turtle
File "/usr/local/lib/python3.9/turtle.py", line 107, in <module>
import tkinter as TK
File "/usr/local/lib/python3.9/tkinter/__init__.py", line 37, in <module>
import _tkinter # If this fails your Python may not be configured for Tk
ModuleNotFoundError: No module named '_tkinter'
I have done the below commands:
sudo apt-get install python3-tk
pip3 install tkinter
pip3 install PythonTurtle
pip3 install Tcl
sudo apt-get install python-tk python3-tk tk-dev
sudo apt-get install python3-PythonTurtle
And, although it is installed, the error still exists. I haven't understand what does wiki says. Could you explain, with all the details, what do I have to do, because I am a newbie at Linux and commands in general?
This error is probably made, because you have installed the tkinter , for instance, on python 3.7, but you are running your code with an interpreter based on python 3.8.
Another reasons, like installing the library in a virtual environment and trying to run the code out of the venv, can also
lead to this error.
Make sure pip and python command are in the same location/path
to make sure they are from the same SDK.
This command indicates where python is installed on your machine:
(Unix Only)
which python
Windows users, use this snippet below to find path of the installed python :
import sys
locate_python = sys.exec_prefix
print(locate_python)
Check the pip location using the which command as well.
which pip
If pip and python are in the same path, you probably won't get the error anymore.
First you have to pay attention to a few things 1- All the packs must be updated and installed If you have downloaded the packs, update them, especially the pip module that is for installation 2- Note that the spelling of the words you use is correct 3 - Maybe the code you write does not support that module, you should also pay attention to this issue 4- Finally, there are some problems in your code. First, to download the Tkinter module, you have to write pip3 install tk or pip install tk. You should not write the word Tkinter yourself. Update the latest version and then try again. If it still does not work, turn on your Windows 10 (if not) and finally the last solution is to change your ide vs code. The best ide for this situation. Is And you can also help to install and import the library of online articles. If you use pycharm, enter the Windows command line and type pip3 install future or pip install future, and then the thinner will be imported for you, and then enter the following command: from future.moves import tkinter and you can find how to install each house in different ideas with a simple search
I want to use 'pynput', so I used pip to add it to my environment.
The installation proceeds without problem.
But I am unable to import it into my project.
I am using python 3.8.1 on my environment.
I used pip3 for installation.
I have already tried to install pynput, uninstall it and reinstall it multiple times.
My .py file doesn't have a confusing name like "pynput.py"
I am comfortable with my environment when I try to execute my file.
I am trying to run from my terminal or VSCodium, and neither of them works.
And I work on Debian 10.
pip freeze :
pynput==1.6.7
python-xlib==0.26
six==1.14.0
Traceback :
Traceback (most recent call last):
File "./play.py", line 6, in <module>
from pynput import keyboard
ModuleNotFoundError: No module named 'pynput'
So I don't understand why it doesn't work.
thank you in advance for your help :)
When creating my project, I was not working under an environment, so I used the classic shebang: #!/bin/python3.
Then, I went under an environment to use pynput, but I just forgot to change my shebang to #!/usr/bin/env python.
So, actually, I didn't risk finding pynput
It might be possible you have two versions. Rry installing with python3 -m pip install pynput or you should use some older version of Python. I am using 3.7.5 and its works perfect for me.
Try importing from the terminal.
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!
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.
You and also do this trick on imports
import subprocess
try:
import pyautogui
except ImportError:
subprocess.call("pip install pyautogui")`
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 >')
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.
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!
Try this...
# Install a pip package in the current Jupyter kernel
import sys
!{sys.executable} -m pip install numpy
Tutorial from Pythonic Perambulations
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
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
make sure that library is installed in same version of python
I have read import error for pyautogui
and this did not answer my question.
I am trying to import pyautogui via the 3.5.2 shell or windows cmd. but when using the shell for:
import pyautogui
Traceback (most recent call last):
File "<pyshell#2>", line 1, in <module>
import pyautogui
ImportError: No module named 'pyautogui'
I have seen people say they resolved by using 3.5 but not for me. I have also seen people say that uninstalling and reinstalling can fix issues. I did this and on reinstall made sure that the path option was selected.
Step one: open windows cmd
Step two: and type in py -3.8 -m pip install pyautogui
You will most likely get a message that says: pip is not up to date, it would look like this: https://i.stack.imgur.com/DOfzQ.png
if you get this error Type in: py -m pip install --upgrade pip
Step three: Open: https://bootstrap.pypa.io/get-pip.py and copy everything on this page
Step four: Open IDLE and run what you just copied
Step five: Open windows cmd again and try py -3.8 -m pip install pyautogui again
Step six: Now try to run it again.
if this doesnt work please show us the errors you get.
Check that you are installing the package using the correct Python Version, in the documentation says that you have to install correspondant to your python version. In my case, I fixed it using python 3.9 (and making sure that my intepreter in VSC is set to Python 3.9.1)
Try doing pip install pyautogui and if it says all requirements are satisfied type in pip show pyautogui and if it shows then just try restarting your IDE and it should work
I am running Windows 7 and using Python 2.7.
I have installed openpyxl using easy_install. It looks like the installation was successful. I changed the directory and fired up Python.
>>> import openpyxl
>>>
So, this should mean that Python is able to find openpyxl. However, when I execute a simple test program excell_tutorial1.py and run it, I get the following:
Traceback (most recent call last):
File "C:/Python27/playground/excell_tutorial1.py", line 7, in <module>
from openpyxl import Workbook
ImportError: No module named openpyxl
Very confusing! It could find it in prompt line but not in the program!
import os, sys
the_module ="C:\\Python27\\Lib\\site-packages\\openpyxl-2.3.3-py2.7.egg\\openpyxl"
if the_module not in sys.path:
sys.path.append(the_module)
if the_module in sys.path:
print sys.path.index(the_module)
print sys.path[18]
so, this gives me:
18
C:\Python27\Lib\site-packages\openpyxl-2.3.3-py2.7.egg\openpyxl
Anyone can think of what the problem might be?
Much appreciated
I had the same problem solved using instead of pip or easy install one of the following commands :
sudo apt-get install python-openpyxl
sudo apt-get install python3-openpyxl
The sudo command also works better for other packages.
While not quite what you ran into here (since you state that you are using python 2.7), for those who run into this issue and are using python 3, you may be unintentionally installing to python 2 instead. To force the install to python 3 (instead of 2) use pip3 instead.
See this thread for more info:
No module named 'openpyxl' - Python 3.4 - Ubuntu
Try deleting all openpyxl material from C:\Python27\Lib\site-packages\
Once you do that try reinstalling it using pip. (This what worked for me)
At times this can be a simple permission issue. As it was in my case. I installed it in my local directory with my login.
python ./setup.py install
but some of the other user were not able to import the module.
They were getting this error:
ImportError: No module named openpyxl
Hence I simply gave exe permission to 'others'
chmod -R 755
That solves the problem at least in my case.
Go to the directory where pip is installed, for eg.C:\Python27\Scripts and open cmd (simply type cmd in address bar ). Now run the command "pip install openpyxl". It will install the package itself. Hope this will solve your problem.
Try this:
!pip install openpyxl
I had the same issue on 3.8.2
I found out that python was installed in two locations on my machine (probably py and python, just a guess)
Here:
C:\Users<userAccount>\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8\LocalCache\local-packages\Python38
and Here:
C:\Python38
I deleted the one in my C drive and everything is working well now. I would double check to see where your packages are getting installed first, before deleting. Which ever one is being used, keep that one.
For this case, check to see where this package got installed:
C:\Users\<userAccount>\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8\LocalCache\local-packages\Python38\site-packages\openpyxl
keep that directory.
What worked for me was to open the terminal as an administrator, cd to the 'scripts' file of where python (different for each version) is stored, and then install using pip:
cd C:\Users\Salfa\AppData\Local\Programs\Python\Python39\Scripts
pip install openpyxl
This resolved the problem for me.