No module named 'pyautogui' - python-3.x

i am using pyautogui for a bot on python 3.7. In the very first line it imports pyautogui
import pyautogui and when i run it it says No module named 'pyautogui' , I tried it with a version of it for 3.7 and 3.8 and upgrading it (because it might have been the cause). I am coding on MS visual studio 2019 and i tried it on 3.7 for 32-bit and 64-bit (none of that seemed to help). Can anyone help me?

For VS 2019 installs:
This artical details how to install it correctly
https://learn.microsoft.com/en-us/visualstudio/python/tutorial-working-with-python-in-visual-studio-step-05-installing-packages?view=vs-2019
For non Visual Studio installs
You will need to install pyautogui with pip.
In the command line run
pip install pyautogui
You can find the install docs for pyautogui here: https://pyautogui.readthedocs.io/en/latest/install.html

Related

tkinter is not recognized as a library when importing it on a pycharm project using python 3.x ¿Why?

if I try to import tkinter in my project, pycharm underlines tkinter as being a missing library.
When I try to install the library, pycharm suggests to import the 'future' library instead of the tkinter library. I don't know why.
If I go to the project interpreter window, I cannot find the tkinter library after clicking on the install packages button.
On the pycharm terminal, if I try to pip install tkinter it returns:
Could not find a version that satisfies the requirement tkinter (from versions: )
No matching distribution found for tkinter
I get the same result when trying pip install python-tk, pip install python3-tk, and pip install tk.
Does anyone know why this is?
I imported the project from windows into Ubuntu Mint 19.1, I am using interpreter Python 3.7.2.
Please let me know if I can add any more useful info.
Install it via apt.
sudo apt-get update && sudo apt install python3-tk
Works for me.
I fixed the issue by uninstalling PyCharm, and reinstalling it from the command line. The previous version I had installed it through the Linux Mint 19.1 Software Manager, and the version installed behaved in very strange ways; for instance it showed a completely different file tree to the one in my machine when trying to setup interpreters.
Here is the command I used, as per JetBrains recommendation:
sudo snap install [pycharm-professional|pycharm-community] --classic
Note: I had to install snap first :)
tkinter is a built in library in python.
install this package :'future' using this command :
pip install future
now import 'tkinter' in your project :
import tkinter

ERROR in install opencv in my python 3.6.6

I HAVE PYTHON 3.6.6 INSTALLED IN MY WINDOWS 7 PLATFORM BUT WHEN I TRIED TO INSTALL OPENCV PACKAGE IT SAYS REQUIREMENT ALREADY SATISFIED AND IF I TRY TO IMPORT CV2 IT SAYS NO MODULE .I'VE TRIED ALL POSSIBLE METHODS ON INTERNET WHAT SHOULD I DO
i tried to download opencv exe from sourceforge and copying cv2.pyd file and then pasting it in site packages
i tried pip install opencv_python-4.0.1-cp37-cp37m-win_amd64.whl
but nothing works
The error message says that you are asking PIP install a version of cv2 for 64-bit Python 2.7, and that installation is failing. So the installation is not happening because it's the wrong version. That might be because you don't have Python 2.7, or because you have a 32-bit processor, or both. Navigate to Python36\Scripts and issue the command pip install opencv_python. Then pip will find the appropriate file to download, and install it.

Error while installing psycopg2 in Windows

I tried to install psycopg2 as:
pip install psycopg2
It was giving error for pg_config. I checked some stackoverflow notes and installed PostgreSQL. Added the path of pg_config in $PATH.
Now it is giving the below error:
LINK : fatal error LNK1181: cannot open input file 'libpq.lib'
error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\BuildTools\\VC\\Tools\\MSVC\\14.14.26428\\bin\\HostX86\\x64\\link.exe' failed with exit status 1181
Any help on this?
Have you tried reinstall without pip?
sudo apt-get install python3-psycopg2
EDIT: Since you're on windows:
You can try this if you're using python 2.7:
pip uninstall psycopg2
pip install git+https://github.com/nwcell/psycopg2-windows.git#win64-py27#egg=psycopg2
If you're using python 3.4:
pip uninstall psycopg2
pip install git+https://github.com/nwcell/psycopg2-windows.git#win64-py34#egg=psycopg2
More info here.
If you prefer, you can download the installer (.exe) and install it.
You can find it here.
I found the issue.... I was using Python 3.7 version. Looks like the latest stable version of psycopg2 (2.7.4) is not yet supported on Python 3.7. It is supported till 3.6
I downgraded my python to 3.6.5 in Anaconda and also to 2.7.15 through PyCharm. I was able to install psycopg2 in both and use them.
Go to https://pypi.org/project/psycopg2
in release history and select the version you want to download.
There will be a table with files and the versions of python that can be compatible with the selected version.
Now download the wheel file that matches your system configuration(mac/linux/win-32/win-64)
I did this and was able to download the package.
For windows10(64-bit), download psycopg2-2.7.7-cp36-cp36m-win_amd64.whl (998.5 kB), in case you have selected 2.7.7
For Windows users, to install the psycopg2 without any errors first install Python 3.7.4 version and then install psycopg2 using command pip install psycopg2 as it worked complete fine with me. I think there is some issue in Python 3.8.0 version onwards because while installing psycopg it is showing an error in setup wheels.
In case you are here in 2020, this is a problem with version 3.8 of python. I had the issue recently. Try using virtualenv so that you can use lower versions of python in your workspace until psycopg2 is supported fully on Python version 3.8

PyQt5-5.8.2 doesn't function on Windows 10

I need to install qscintilla. I use pip for that:
> pip install qscintilla
PyQt5 automatically upgrades to the latest version '5.8.2', and sip upgrades to '4.19.2'. I suppose this has to do with the needs of qscintilla. Perhaps the latest version of qscintilla needs the latest PyQt version to operate properly.
Unfortunately, PyQt5-5.8.2 combined with sip-4.19.2 don't work on Windows 10. I get the following error:
> python
>>> import PyQt5.QtWidgets
ImportError: DLL load failed: The specified module could not be found.
I have checked my PATH variable in Windows 10, and I found the following directory: C:\Anaconda3\Library\bin. I've checked that folder, and the dll's are all present: Qt5Widgets.dll, 'Qt5Gui.dll`, ... So I can hardly believe that Python cannot find them.
I will now go through the things I've tried so far.
1. Clean install of Anaconda => upgrade PyQt5.
I've removed Python completely from my PC, and installed Anaconda from scratch: Python 3.6 for Windows 64-bit.
Anaconda is shipped with an older version of PyQt5. I check the version like this:
> python
>>> from PyQt5.QtCore import QT_VERSION_STR
>>> from PyQt5.Qt import PYQT_VERSION_STR
>>> from sip import SIP_VERSION_STR
>>>
>>> QT_VERSION_STR
>>> '5.6.2'
>>> PYQT_VERSION_STR
>>> '5.6'
>>> SIP_VERSION_STR
>>> '4.18'
I simply upgrade my PyQt version, because I know that the qscintilla installation would do that anyway. If the problem is present after upgrading PyQt (and before installing qscintilla), I can rule out possible problems caused by the qscintilla installation. So here we go:
> pip install pyqt5 --upgrade
Collecting pyqt5
...
Successfully installed pyqt5-5.8.2 sip-4.19.2
As I expected, the upgraded version of pyqt results in the error:
> python
>>> import PyQt5.QtWidgets
ImportError: DLL load failed: The specified module could not be found.
2. Install PyQt5-5.7.1 instead of PyQt5-5.8.2.
I've found a wheel file from PyQt5-5.7.1 on this page: https://pypi.python.org/pypi/PyQt5/5.7.1
I hope that qscintilla will work on this one too. After all, it is a quite recent version. But first, I want to find out if I get it installed properly, and if the error above has gone.
> pip uninstall PyQt5
> pip uninstall sip
>
> pip install C:\..\Downloads\PyQt5-5.7.1-5.7.1-cp34.cp35.cp36-none-win_amd64.whl --no-cache-dir
...
Successfully installed pyqt5-5.7.1 sip-4.19.2
Unfortunately, the error persists.
3. Answers from StackOverflow.
I've checked several posts on StackOverflow, but none of them helped me out.
This post is too old: PyQt5 : The DLL load failed : the specified module could not be found
This post gives a possible reason: "Probably it's because pyqt .pyd files are linked against python3.dll, and not python3.6 dll." DLL load failed when importing PyQt5 . The answer suggests that I should use an older version of PyQt5. I've tried that (see above), but it still fails. The answer also suggests to build PyQt5 from the source code. I've tried that as well, but the build process gets stuck..
Can anyone help me? Perhaps you have successfully built the latest PyQt5-5.8.2 version from source code into a wheel file? I would be so happy if you share that file.
The root issue for me was different versions of PyQt wheel (5.9) and pyqt windows distro (5.6 - the last precompiled version available).
I found matching 5.6 wheel, but it only supported Python 3.5.
So, I downgraded Python to 3.5 and installed PyQt5-5.6-cp35-none-win_amd64.whl
pip install pyqt5==5.6
works equally well.
I found a workaround: don't use Anaconda. I deleted Anaconda from my PC and did a fresh install like this:
1. Install Python 64-bit
Download the 64-bit installer for Windows from this URL: https://www.python.org/downloads/release/python-361/
Make sure to include pip when asked for the installation options!
2. Install PyQt5
Install PyQt5 by typing the following in your Windows command terminal:
> pip install PyQt5 --no-cache-dir
...
Successfully installed PyQt5-5.8.2 sip-4.19.2
The --no-cache-dir option makes sure that pip will not use an old version stored somewhere on your computer, but download the latest one instead.
3. Install QScintilla
Install QScintilla like this:
> pip install qscintilla --no-cache-dir
Successfully installed qscintilla-2.10
It does work on windows 10. Your application failed to access specified DLL. A restart is required to get it working. I went through all the answers in the SO forums and it turns out a computer restart can set everything straight. so restart your pc.

Import external library to Pycharm

I just installed Pycharm, I tried to install Matplotlib using preferences->project interpreter, but I am getting an error.
So I have used the terminal to install it: sudo pip install matplotlib. The installation was successful but I don't know how to import that to pycharm.
Can anybody help me please ?
If you installed matplotlib to the Python interpreter assigned to your project there is nothing else you have to do. Go to Preferences -> Project Interpreter and check if matplotlib is there. It should be.
Edit: Here is a visual guide to where exactly it is:

Resources