Problem In Installing MySql Connector for Python - python

Hi I have just started learning sql language in MySql and have completed basic level of the language.
Now I want to access mysql databases from python. I got to know that we need to install MYSQL_Connector for Python to achieve this goal.
But, When i tried to install python-connector for mysql it gives an error that python version not found/
I tried to install it but it failed even though i have python 3.11.0 installed on my pc.
I tried to Reinstall both python and mYsql but it Doesn't worked.
Please help me with this problem

With the error that you've described, it seems that you're using the Windows MSI installer. But there's an issue in the Connector/Python 8.0.31 installer for Python 3.11, that will be fixed in the upcoming release, see https://bugs.mysql.com/bug.php?id=108911
Meanwhile, the solution is performing the installation using the wheel package, actually it's the recommended way of installing Connector/Python.
As described by Oscar in the bug report above, you can run:
Console (CMD or PowerShell)
--------------------------------
> pip install mysql-connector-python
or
> python -m pip install mysql-connector-python

Related

Download python library from Github "requires a different Python"

I'm trying to download python library from github, by using this comand in cmd: pip install --upgrade --force-reinstall https://github.com/BurnySc2/python-sc2/archive/develop.zip
But in the end, I catch an error:
ERROR: Package 'burnysc2' requires a different Python: 3.10.2 not in
'<3.10,>=3.7'
I have the latest version of Python (3.10.2)
Is there any ways to solve this problem?
That library doesn't officially support Python 3.10, as the error message says.
I have the latest version of Python (3.10.2) Is there any ways to solve this problem?
I believe you can try adding --python-version 3.9 to your command. This should let you install with Python 3.10 even though it isn't officially supported:
The Python interpreter version to use for wheel and “Requires-Python” compatibility checks. Defaults to a version derived from the running interpreter.
If this works and all tests pass, consider changing the version constraint to include Python 3.10 and submitting a pull request.
Or you could downgrade to Python 3.9.
try download the wheel file and force install it using
pip install <package-name> --ignore-requires-python --target <directory>
but it probably won't work

mysql-connector-python is not working on VS Code and working in python shell

I am trying to connect to MySQL database, but strangly
mysql-connector-python is working in python shell, and not using VS Code.
I tried installing the following packages:
pip install mysql-connector
pip install mysql-connector-python
pip install mysql-connector-python-rf
No luck either. So, I uninstalled all packages then reinstalled only mysql-connector-python, then rebooted, to make sure there was no issue in this regard.
The error is:
ModuleNotFoundError: No module named 'mysql.connector'; 'mysql' is not a package
Python version: 3.9.4
VS Code: 1.6.20
Here are some screenshots:
The main issue was related to code runner.
uninstall, then install did the trick.
I often face some error because of code runner not connecting to the right environment or not reading new package.
Normally, restarting the visual studio code session or the whole software solve it, but not in this case.

cqlsh connection error: 'ref() does not take keyword arguments'

I've tried all the measures from this post and Cassandra doc.
I've tried running all the versions of Cassandra including the latest release 3.7 from tarball and Debian package, but I keep getting errors when I execute cqlsh.
Error:
Connection error: ('Unable to connect to any servers', {'127.0.0.1': TypeError('ref() does not take keyword arguments',)})
I had no problem running Cassandra before I upgraded my Linux Mint from 17.3 to 18.
I believe I installed all the necessary packages such as java 8 and python 2.7.12.
I think the problem exists in cassandra.yaml file since the default setting isn't working, but I'm not sure how to configure properly to get it running.
Any suggestions appreciated.
You are running into CASSANDRA-11850, where cqlsh breaks with Python 2.7.11+. This ticket has been marked as "Resolved" and a patch has been applied to Cassandra 3.9 which has not been released yet.
I believe I installed all the necessary packages such as java 8 and python 2.7.12.
In the interim (until 3.9 is released) you can roll back to Python 2.7.10, and cqlsh should work (not trivial). Otherwise, DataStax DevCenter should work with Cassandra 3.7.
Edit 20161020
Cassandra 3.9 was released a few weeks ago, and can now be downloaded.
refer https://issues.apache.org/jira/browse/CASSANDRA-11850
After setting environment variable
CQLSH_NO_BUNDLED=TRUE
it resolved.
I use windows 7, python 2.7.12, cassandra 3.7
Need to add following command
sudo apt install python-pip
pip install cassandra-driver
export CQLSH_NO_BUNDLED=true
This works for Ubuntu 16.04 in Amazon EC2:
sudo apt-get --no-install-recommends install python-cassandra python3-cassandra
CQLSH_NO_BUNDLED=TRUE cqlsh "$(ec2metadata --local-ipv4)"
Even if after rolling back to python 2.7.10, the issue persists. It means the python 2.7.10 is not set as the default python version.
Go to /usr/bin directory and check the different python versions available, say python2.7 corresponds to version 2.7.10 ( you can check it by running command python2.7 in your terminal and the python version will be mentioned in the first line of the Interpreter,try the same with all other python versions available in the folder to find the one which corresponds to version 2.7.10).
Now, use the following commands to make correct python version (python2.7 in my case) as default choice
update-alternatives --install /usr/bin/python python /usr/bin/python2.7
It may be possible as you have not installed cassandra-driver.
As I also faced the same problem and I solved using following such steps.
Try installing python pip then install cassandra-driver.
1.sudo apt install python-pip
2.pip install cassandra-driver

Installing Python with MySQL connector on Red Hat

I'm having trouble making MySQL connector work with Python.
I started with a fresh new installation of Red Hat 6.4.
The system already had Python 2.6.6 installed by default, I need however version 3.4
I downloaded, compiled and installed Python 3.4 from here (https://www.python.org/ftp/python/3.4.4/Python-3.4.4.tgz)
I downloaded and installed the MySQL yum repository from here (http://dev.mysql.com/get/mysql57-community-release-el6-8.noarch.rpm)
Installed mysql-community-server version 5.7 with yum
Finally I installed mysql-connector-python with yum (version 2.1.3)
Now it looks like the module works in Python 2.6.6 but it can't find the module with Python 3.4.
I'm a bit stuck with how to get round this.
Since you got the mysql-connector via yum, it's installed for the system python. Your custom python 3 environment doesn't know about it.
So it's probably best to do the following:
Get pip and install it for your python 3. Make sure that python points to your custom installation when executing python get_pip.py
Get the source distribution of the mysql-connector: https://dev.mysql.com/get/Downloads/Connector-Python/mysql-connector-python-2.1.3.tar.gz
Use your just installed pip to install the mysql-connector from source into your python environment: pip install path/to/mysql-connector-python-2.1.3.tar.gz
Alternatively you might look into using virtualenv.

Python 3.5 MySQL Connector

I'm somewhat new to python and figured playing around with mySQL databases would be a good idea.
Now the error I am having is simply installing the mySQL connector. I have tried on both my Windows PC, and now here on my mac.
Each time I download the connector and install it, all goes ahead and installs, yet when I import mysql.connector I receive a traceback, ImportError saying that mysql is not a package.
I've been searching the internet trying to find information or ways to help this, but non have been successful.
It should be noted that I have restarted my computer, still with no success.
I installed python 3.5 via the official python website, and the mysql connector via the official mysql website.
You need to provide more information. Could tell us how you installed the connector? easy_install? pip? Are you on Python2 or Python3. On windows are you using the official Python installer or did you install Python via Cygwin?
Typically, after you install a Python package, you'll find it in the following location on Mac/Linux:
/usr/lib/python<version>/site-packages/
On Windows you'll find site-packages under the Python directory in C:\Program Files.
Which MySQL connector have you installed (there are several)?
Also, ensure you've installed the connector for the correct Python version. If you're using Python2, but are using pip3 to install the package, then pip will install it to the python3 site-packages and you won't be able to access it from Python2.

Categories