Here is my code:
import pyautogui
cord = pyautogui.locateOnScreen('chrome.png')
pyautogui.doubleClick(cord)'
However, I got this error:
I installed Pillow and imported PIL
I also installed opencv and numpy.
Through some research I realised it could be some site-package issues/ environment issues. I uninstalled and reinstalled python and updated the PATH.
please help I am at my wits end.
Known problem - i had it too. Maybe downgrade to 3.8 OR even 3.7.
I had to downgrade to 3.7 because a module in pyautoGUI made my script crash.
I'm trying to connect to a mySQL database through SQLAlchemy and I can't get it to work for the life of me. Here's the code I'm running and the error I'm getting.
import pandas as pd
import sqlalchemy as sql
import urllib.parse
user = 'user'
pswd = urllib.parse.quote_plus('password')
connect_string = 'mysql://{}:{}#localhost:8018/test'.format(user, pswd)
sql_engine = sql.create_engine(connect_string)
>>> ModuleNotFoundError: No module named 'MySQLdb'
After seeing this, I've tried numerous different ways of installing 'MySQLdb' ( including the obvious 'pip3 install mysqlclient') and when I run that in my terminal, I get the following.
>>> ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
I know this question has been posted here before but I've spent 2 hours now trying to figure this out with the advice on those other questions and nothing is working. Can anyone help? Below is a picture of the full error I'm getting when I try and install "mysqlclient"
According to
https://pypi.org/project/mysqlclient/#files
mysqlclient only offers pre-compiled wheel files for Windows machines running 64-bit Python 3.6, 3.7, and 3.8. All other configurations require that it be installed from source, and that can be ... complicated.
You may want to try installing PyMySQL instead, and use a connection URI of the form
mysql+pymysql://<username>:<password>#<host>/<dbname>[?<options>]
SQLAlchemy is a high-level ORM. To connect to backends it needs Python DB API driver(s). You can install SQLAlchemy with a MySQL driver using
pip install -U 'SQLAlchemy[mysql]'
See the list of extra drivers available for such installation.
Most drivers have parts written in C/C++ and thus require compilation. You need to install MySQL-related libraries to compile mysqlclient. See https://stackoverflow.com/search?q=%5Bpip%5D+install+%5Bmysql%5D+%22mysql_config%22+not+found
There are a few pure-Python drivers. They're easier to install. PyMySQL is one such driver. To install it along with SQLAlchemy:
pip install -U 'SQLAlchemy[pymysql]'
I've trawled the forums but cannot find an answer or even any documentation on this. Trying to re-create a site like www.testandtrack.io
On running the command:
python manage.py inspectdb
I get the error:
mysqlclient 1.3.13 or newer is required; you have 0.9.3
I have tried all the suggested fixes including:
-upgrading pip
-installing a different wheel (32 bit instead of 64), namely mysqlclient-1.4.2-cp37-cp37m-win32.whl with the command pip install mysqlclient-1.4.2-cp37-cp37m-win32.whl (this works fine without an error but doesn't do the job required!)
My objective is to simply connect a legacy mysql database (running inside of XAMPP and myphpadmin) to Django. I've followed the documentation which misses out the need to install mysqlclient, and have got stuck at this point.
I guess your project uses pymysql instead of mysqlclient.
You can try to search the following code snippet in your project. If you find it, please try the following methods to fix this problem:
import pymysql
pymysql.install_as_MySQLdb()
Insert a line of code between these two to make it look like this:
import pymysql
pymysql.version_info = (1, 3, 13, "final", 0)
pymysql.install_as_MySQLdb()
Then try to start your project.
Why do I know you are using pymysql? Because 0.9.3 is just the latest version of pymysql.
Why use pymysql instead of mysqlclient for the project? Because it is easier to install. pymysql does not depend on system libraries, while mysqlclient relies on a series of system libraries such as libmysqlclient-dev.
Why is mysqlclient difficult to install and Django still uses it by default? Because mysqlclient is faster and performs better. So if your project has high performance requirements, I suggest you remove the compatible code above and install mysqlclient in your project. If you need help during the installation of mysqlclient, please refer to this link: How to install Python MySQLdb module using pip?, and ensure libssl-dev has been installed before pip install mysqlclient.
This is how I fixed it.
Go to your django/db/backends/mysql installation dir.
Check your path in the error message.
I'm using pipenv so my path is:
/home/username/.local/share/virtualenvs/project-env/lib/python3.7/site-packages/django/db/backends/mysql
If you use traditional env your path would be:
<env_directory_name>/Lib/site-packages/django/db/base.py
Open file base.py and search for:
version = Database.version_info
Put a pass inside if and comment line:
raise ImproperlyConfigured('mysqlclient 1.3.13 or newer is required;
you have %s.' % Database.version)
Like this.
if version < (1, 3, 13):
pass
'''
raise ImproperlyConfigured(
'mysqlclient 1.3.13 or newer is required; you have %s.'
% Database.__version__
)
'''
Save, close this file and open operations.py.
Search for:
query = query.decode(errors='replace')
and change decode to encode
query = query.encode(errors='replace')
Now, try to run the server.
#edit
Until this answer, I found no other way to solve it. Today there are better ways to deal with this problem. This answer has a better approach.
I have had the same issue as lower version of mysqlclient was installed due to pymysql.
OS: Linux Mint 19.1
Python: 3.6.8
Django: 2.2.2
Uninstall mysqlclient: pip3 uninstall mysqlclient
Uninstall pymysql: pip3 uninstall pymysql
Install mysqlclient: pip3 install mysqlclient
this problem occurs when you create Django project in pycharm by default settings.
It's caused by the default version of django is 2.2.6, so just downgrade the django version to 2.1.7, and error in the terminal is gone.
pip install Django==2.1.7
that's all!
Instead of edit internal configuration, try to upgrade the version of mysqlclient
pip3 install -U mysqlclient
The following solution works in Django 3.2.3 to get rid of the 'mysqlclient 1.3.13 or newer is required; you have 0.9.3' problem:
1) pip uninstall mysqlclient # remove old version
2) pip install mysqlclient==1.3.13
3) comment or remove the old workaround in __init__.py of the main app.
# workaround django.core.exceptions.ImproperlyConfigured:
#Error loading MySQLdb module.
#Did you install mysqlclient?
#import pymysql
#pymysql.install_as_MySQLdb()
Install wheel:
pip install wheel
Download file that you want from here: https://www.lfd.uci.edu/~gohlke/pythonlibs/#mysql-python
Move to your Downloads directory (I guess it'll be cd Downloads)
Install downloaded file with: pip install <file name>
WARNING!! You CANT edit name of downloaded .whl file. It contains some information what is required to install.
It worked fine with me just open settings.py and include
import pymysql
pymysql.version_info = (1, 4, 6, 'final', 0)
pymysql.install_as_MySQLdb()
I had a similar issue, I was getting
"django.core.exceptions.ImproperlyConfigured: mysqlclient 1.3.13 or newer is required; you have 1.3.12."
So I went to the C:\Users\username\Envs\env\Lib\site-packages\django\db\backends\mysql, opened base.py and changed that line...
if version < (1, 3, 13):
to...
if version < (1, 3, 10):
which is a version lesser than mine and it worked.
If it's not critical for you, as a variant, just downgrade your django framework from 2.2.2(for example) to 2.1.
I was finding a solution for this issue from a long time. I was using Ubuntu 18.04 and found this solution to be useful for python version 3.7.5
Step 1. Install libpython3.7-dev via sudo apt-get install
> sudo apt-get install libpython3.7-dev
Step 2: Install mysqlclient
> python3 -m pip install mysqlclient==1.4.6
If you are working with Django on ubuntu, i will suggest you do the following to resolve the issue than editing django specific configuration files
run the following commands in the terminal
sudo apt-get install python3-dev default-libmysqlclient-dev build-essential
pip install mysqlclient
Maybe your Django project uses pymysql, instead of upgrading mysqlclient, just do
pip install pymysql -U
This works for me ! :D
There are the same issue on github. Solution that perfectly fits for me is here.
I just quote an author:
I first pip uninstall pymysql (as it seems it doesn't work anymore)
Then I've used pip install mysqlclient
Last, I checked all my "pymysql" imports and deleted them.
Be sure to go and hit a like button on the comment in the link
Go to your virtual environment directory like mine:
C:\Users\user\.virtualenvs\RPA-Orchestrator-Backend-GwIL98hN\Lib\site-packages\django\db\backends\mysql\base.py
Here you might edit one line to avoid your error in the base.py file,
version = Database.version_info
if version < (0, 9, 3):
raise ImproperlyConfigured('mysqlclient 1.3.13 or newer is required; you have %s.' % Database.__version__)
Then your problem might solve.
I have spent hours trying multiple approaches to install MYSQLDB module for python, and no success.
My python version: 2.7.6
Django - 1.10.3
OS: Windows 7 64-bit
MySQL connector - MySQL Connector C 6.0.2
Currently I have an error in my project, namely:
django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module: No module named MySQLdb
I have tried to install mysqldb running the following command:
pip install mysql-python
It ran successfully, but the error still persisted. Then I tried to run
pip install MySQL-python
and I am getting Cannot open include file config-win.h.
I came across this post, but I don't understand the idea of the answer, specifically, I can't figure out where I should look for the mentioned files site.cfg and setup_windows.py. There are no such files in C:\Program Files\MySQL\MySQL Connector C 6.0.2\include
Finally, I tried to install MySQLDb using wheels running
pip install mysqlclient-1.3.9-cp27-cp27m-win_amd64.whl command, I end up with
mysqlclient-1.3.9-cp27-cp27m-win_amd64.whl is not a supported wheel on this platform error.
I have lost my hope. Help please !!!
Try to install 32 bit version mysqlclient-1.3.9-cp27-cp27m-win32.whl
If it doesn't work try to install it from (where you can find compiled windows libraries):
http://www.lfd.uci.edu/~gohlke/pythonlibs/
I am getting ImportError: No module named 'mysql' while I do the following...
>>> import mysql.connector
MySQL is installed and am on Python 3.5. I can't figure out. The above command is running fine in Python 2.7.
Unfortunately there is no mysql-connector available for python3.5.
So, you can use pymysql module which is a replacement for mysql-connector package
pip install pymysql
import pymysql
Connection = pymysql.connect(host='hostname', user='username', password='password',
db='database',charset='utf8mb4',cursorclass=pymysql.cursors.DictCursor )
ExecuteQuery(Connection)
Connection.close()
For me (OS X 10.11.4, Python 3.5.1), the mysql-connector-package installed itself (by default) into Python 2.7 that was also on my system. I copied the mysql package directory from:
/Library/Python/2.7/site-packages/mysql to /Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/mysql. Everything works. According to http://dev.mysql.com/doc/connector-python/en/connector-python-versions.html the connector package supports Python 3.3+.
Your specific installation path for the module may be different, but you can easily check this from the REPL using the sys.path:
https://leemendelowitz.github.io/blog/how-does-python-find-packages.html
As we need to be connecting MySQl with Python, the Python command assumes that the connector is enabled. So we need to follow the steps below:
open MySQL Installer;
go to "Custom settings";
go to "Connectors";
choose the connector\Python and version based on the one you are using;
add it;
use import mysql.connector.
It should run, in my case it did!
From Can't run MySql Utilities:
MYSQL Utilities assumes that the MySQL Connector for Python has been installed. If you install it (http://dev.mysql.com/downloads/connector/python/), MySQL Utilities should run OK.
I think this link may help you to solve your problem.